Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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
        }
Ejemplo n.º 3
0
 public LuaVMDBCache(DbCache <TValue> _dbCache)
 {
     dbCache = _dbCache;
 }