BitSharp.Esent.EsentChainStateCursor.TryGetHeader C# (CSharp) Method

TryGetHeader() public method

public TryGetHeader ( UInt256 blockHash, ChainedHeader &header ) : bool
blockHash UInt256
header ChainedHeader
return bool
        public bool TryGetHeader(UInt256 blockHash, out ChainedHeader header)
        {
            CheckTransaction();

            using (SetSessionContext())
            {
                Api.JetSetCurrentIndex(this.jetSession, this.headersTableId, "IX_BlockHash");
                Api.MakeKey(this.jetSession, this.headersTableId, DbEncoder.EncodeUInt256(blockHash), MakeKeyGrbit.NewKey);
                if (Api.TrySeek(this.jetSession, this.headersTableId, SeekGrbit.SeekEQ))
                {
                    var headerBytes = Api.RetrieveColumn(this.jetSession, this.headersTableId, this.headerBytesColumnId);

                    header = DataDecoder.DecodeChainedHeader(headerBytes);
                    return true;
                }

                header = default(ChainedHeader);
                return false;
            }
        }