示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="db"></param>
        /// <param name="key"></param>
        /// <returns>Can return null or empty Span on missing key</returns>
        /// <exception cref="InvalidOperationException"></exception>
        public static Span <byte> GetSpan(this IDbWithSpan db, Keccak key)
        {
#if DEBUG
            if (key == Keccak.OfAnEmptyString)
            {
                throw new InvalidOperationException();
            }
#endif

            return(db.GetSpan(key.Bytes));
        }
示例#2
0
        public PersistentReceiptStorage(IColumnsDb <ReceiptsColumns> receiptsDb, ISpecProvider specProvider, IReceiptsRecovery receiptsRecovery)
        {
            long Get(Keccak key, long defaultValue) => _database.Get(key)?.ToLongFromBigEndianByteArrayWithoutLeadingZeros() ?? defaultValue;

            _database         = receiptsDb ?? throw new ArgumentNullException(nameof(receiptsDb));
            _specProvider     = specProvider ?? throw new ArgumentNullException(nameof(specProvider));
            _receiptsRecovery = receiptsRecovery ?? throw new ArgumentNullException(nameof(receiptsRecovery));
            _blocksDb         = _database.GetColumnDb(ReceiptsColumns.Blocks);
            _transactionDb    = _database.GetColumnDb(ReceiptsColumns.Transactions);

            byte[] lowestBytes = _database.Get(Keccak.Zero);
            _lowestInsertedReceiptBlock = lowestBytes == null ? (long?)null : new RlpStream(lowestBytes).DecodeLong();
            _migratedBlockNumber        = Get(MigrationBlockNumberKey, long.MaxValue);
        }
示例#3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="db"></param>
 /// <param name="key"></param>
 /// <returns>Can return null or empty Span on missing key</returns>
 public static Span <byte> GetSpan(this IDbWithSpan db, long key) => db.GetSpan(key.ToBigEndianByteArrayWithoutLeadingZeros());