Exemplo n.º 1
0
        public void PersistLevel(long number, ChainLevelInfo level, BatchWrite batch = null)
        {
            void PersistLevel()
            {
                _blockInfoCache.Set(number, level);
                _blockInfoDb.Set(number, Rlp.Encode(level).Bytes);
            }

            bool needLock = batch?.Disposed != false;

            if (needLock)
            {
                lock (_writeLock)
                {
                    PersistLevel();
                }
            }
            else
            {
                PersistLevel();
            }
        }
Exemplo n.º 2
0
        public void Delete(long number, BatchWrite batch = null)
        {
            void Delete()
            {
                _blockInfoCache.Delete(number);
                _blockInfoDb.Delete(number);
            }

            bool needLock = batch?.Disposed != false;

            if (needLock)
            {
                lock (_writeLock)
                {
                    Delete();
                }
            }
            else
            {
                Delete();
            }
        }