Beispiel #1
0
        private (int Total, int Txs, int Ommers) GetContentLength(Block item, RlpBehaviors rlpBehaviors)
        {
            int contentLength = _headerDecoder.GetLength(item.Header, rlpBehaviors);

            int txLength = GetTxLength(item, rlpBehaviors);

            contentLength += Rlp.GetSequenceRlpLength(txLength);

            int ommersLength = GetOmmersLength(item, rlpBehaviors);

            contentLength += Rlp.GetSequenceRlpLength(ommersLength);

            return(contentLength, txLength, ommersLength);
        }
Beispiel #2
0
        private (int Total, int Topics) GetContentLength(LogEntry item)
        {
            var contentLength = 0;

            if (item == null)
            {
                return(contentLength, 0);
            }

            contentLength += Rlp.LengthOf(item.LoggersAddress);

            int topicsLength = GetTopicsLength(item);

            contentLength += Rlp.GetSequenceRlpLength(topicsLength);
            contentLength += Rlp.LengthOf(item.Data);

            return(contentLength, topicsLength);
        }
Beispiel #3
0
        private (int Total, int Logs) GetContentLength(TxReceipt item, RlpBehaviors rlpBehaviors)
        {
            var contentLength = 0;
            var logsLength    = 0;

            if (item == null)
            {
                return(contentLength, 0);
            }
            bool isStorage = (rlpBehaviors & RlpBehaviors.Storage) != 0;

            if (isStorage)
            {
                contentLength += Rlp.LengthOf(item.BlockHash);
                contentLength += Rlp.LengthOf(item.BlockNumber);
                contentLength += Rlp.LengthOf(item.Index);
                contentLength += Rlp.LengthOf(item.Sender);
                contentLength += Rlp.LengthOf(item.Recipient);
                contentLength += Rlp.LengthOf(item.ContractAddress);
                contentLength += Rlp.LengthOf(item.GasUsed);
                contentLength += Rlp.LengthOf(item.Error);
            }

            contentLength += Rlp.LengthOf(item.GasUsedTotal);
            contentLength += Rlp.LengthOf(item.Bloom);

            logsLength     = GetLogsLength(item);
            contentLength += Rlp.GetSequenceRlpLength(logsLength);

            bool isEip658receipts = (rlpBehaviors & RlpBehaviors.Eip658Receipts) == RlpBehaviors.Eip658Receipts;

            if (isEip658receipts)
            {
                contentLength += Rlp.LengthOf(item.StatusCode);
            }
            else
            {
                contentLength += Rlp.LengthOf(item.PostTransactionState);
            }

            return(contentLength, logsLength);
        }
Beispiel #4
0
 public int GetLength(Transaction item, RlpBehaviors rlpBehaviors)
 {
     return(Rlp.GetSequenceRlpLength(GetContentLength(item, false)));
 }