public LevelDBStore Init(string path) { var options = new Options() { BlockSize = 8 * 1024 * 1024, // 8M Cache = new Cache(100 * 1024 * 1024), // Äڴ滺´æ 100M CompressionLevel = CompressionLevel.SnappyCompression, CreateIfMissing = true, }; this.db = new DB(options, path); Blocks = new DbCache <Block>(db, null, null, null, "Blocks"); Heights = new DbCache <List <string> >(db, null, null, null, "Heights"); return(this); }
public DbSnapshot(DB db, long height, bool bUndo, bool bWrite) { #if MultiThread this.bWrite = bWrite; if (this.bWrite) { Monitor.Enter(db); } this.db = db; this.snapshot = db.CreateSnapshot(); this.batch = bWrite ? new WriteBatch() : null; #else Monitor.Enter(db); this.db = db; this.snapshot = db.CreateSnapshot(); this.batch = new WriteBatch(); #endif this.options = new ReadOptions { FillCache = false, Snapshot = snapshot }; if (bUndo) { Undos = new DbUndo(); Undos.height = height; long.TryParse(db.Get("UndoHeight"), out long UndoHeight); if (UndoHeight + 1 != Undos.height) { throw new InvalidOperationException($"{UndoHeight} heightTotal+1 != Undos.height {Undos.height}"); } } Snap = new DbCache <string>(db, options, batch, Undos, "Snap"); Blocks = new DbCache <Block>(db, options, batch, null, "Blocks"); Heights = new DbCache <List <string> >(db, options, batch, null, "Heights"); Transfers = new DbCache <BlockSub>(db, options, batch, Undos, "Trans"); Accounts = new DbCache <Account>(db, options, batch, Undos, "Accounts"); Contracts = new DbCache <LuaVMScript>(db, options, batch, Undos, "Contracts"); Storages = new DbCache <LuaVMContext>(db, options, batch, Undos, "Storages"); BlockChains = new DbCache <BlockChain>(db, options, batch, Undos, "BlockChain"); StoragesMap = new DbCache <string>(db, options, batch, Undos, "StgMap"); ABC = new DbCache <List <string> >(db, options, batch, Undos, "ABC"); List = new DbList <string>(db, options, batch, Undos, "List"); Queue = new DbQueue <string>(db, options, batch, Undos, "Queue", 1260); // (60/8) * 24Hour * 7Day }
public LuaVMDBCache(DbCache <TValue> _dbCache) { dbCache = _dbCache; }