Beispiel #1
0
        private void Delete(byte[] key, bool tryCommit = true)
        {
            batch.Delete(key);
            var keyHash = key.Keccak();

            _memDb[keyHash] = null;
            DbShrinkUtils.UpdateCounter();
            if (tryCommit && DbShrinkUtils.CycleEnded())
            {
                Commit();
            }
        }
Beispiel #2
0
        public void AddAndRemoveTransaction(TransactionReceipt txToAdd, TransactionReceipt txToRemove)
        {
            /* write transaction to storage */
            var batch    = new RocksDbAtomicWrite(_rocksDbContext);
            var prefixTx = EntryPrefix.TransactionByHash.BuildPrefix(txToRemove.Hash);

            batch.Delete(prefixTx);
            prefixTx = EntryPrefix.TransactionByHash.BuildPrefix(txToAdd.Hash);
            batch.Put(prefixTx, txToAdd.ToByteArray());
            /* add transaction to pool */
            var pool = GetTransactionPool();

            pool.Remove(txToRemove.Hash);
            if (!pool.Contains(txToAdd.Hash))
            {
                pool.Add(txToAdd.Hash);
            }
            prefixTx = EntryPrefix.TransactionPool.BuildPrefix();
            batch.Put(prefixTx, pool.TransactionHashListToByteArray());
            batch.Commit();
        }
Beispiel #3
0
        public void DeleteNodeToBatch(ulong id, RocksDbAtomicWrite tx)
        {
            var prefix = EntryPrefix.PersistentHashMap.BuildPrefix(id);

            tx.Delete(prefix);
        }