Esempio n. 1
0
        public void CommitNodes()
        {
            RocksDbAtomicWrite tx = new RocksDbAtomicWrite(_dbContext);

            foreach (var item in _nodeCache)
            {
                tx.Put(EntryPrefix.PersistentHashMap.BuildPrefix(item.Key), NodeSerializer.ToBytes(item.Value));
                Console.WriteLine("Adding node to DB : " + item.Key);
            }
            ulong nodesCnt = UInt64Utils.FromBytes(_dbContext.Get(EntryPrefix.NodesDownloadedTillNow.BuildPrefix()));

            nodesCnt += (ulong)_nodeCache.Count;
            tx.Put(EntryPrefix.NodesDownloadedTillNow.BuildPrefix(), UInt64Utils.ToBytes(nodesCnt));
            tx.Commit();
            _nodeCache.Clear();
        }