5 #ifndef BITCOIN_BLOCKENCODINGS_H 6 #define BITCOIN_BLOCKENCODINGS_H 22 template<
typename Stream,
typename I>
23 void Ser(Stream& s, I v)
25 if (v < m_shift || v >= std::numeric_limits<uint64_t>::max())
throw std::ios_base::failure(
"differential value overflow");
27 m_shift = uint64_t(v) + 1;
29 template<
typename Stream,
typename I>
34 if (m_shift < n || m_shift >= std::numeric_limits<uint64_t>::max() || m_shift < std::numeric_limits<I>::min() || m_shift > std::numeric_limits<I>::max())
throw std::ios_base::failure(
"differential value overflow");
55 std::vector<CTransactionRef>
txn;
59 blockhash(req.blockhash), txn(req.indexes.size()) {}
91 void FillShortTxIDSelector()
const;
100 static constexpr
int SHORTTXIDS_LENGTH = 6;
109 uint64_t GetShortID(
const uint256& txhash)
const;
111 size_t BlockTxCount()
const {
return shorttxids.size() + prefilledtxn.size(); }
116 if (ser_action.ForRead()) {
117 if (obj.BlockTxCount() > std::numeric_limits<uint16_t>::max()) {
118 throw std::ios_base::failure(
"indexes overflowed 16 bits");
120 obj.FillShortTxIDSelector();
128 size_t prefilled_count = 0, mempool_count = 0, extra_count = 0;
136 bool IsTxAvailable(
size_t index)
const;
137 ReadStatus FillBlock(
CBlock& block,
const std::vector<CTransactionRef>& vtx_missing);
140 #endif // BITCOIN_BLOCKENCODINGS_H std::shared_ptr< const CTransaction > CTransactionRef
enum ReadStatus_t ReadStatus
CBlockHeaderAndShortTxIDs()
size_t BlockTxCount() const
uint64_t ReadCompactSize(Stream &is, bool range_check=true)
Decode a CompactSize-encoded variable-length integer.
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
std::vector< uint16_t > indexes
std::vector< CTransactionRef > txn_available
BlockTransactions(const BlockTransactionsRequest &req)
PartiallyDownloadedBlock(CTxMemPool *poolIn)
static Wrapper< Formatter, T & > Using(T &&t)
Cause serialization/deserialization of an object to be done using a specified formatter class...
SERIALIZE_METHODS(PrefilledTransaction, obj)
std::vector< CTransactionRef > txn
SERIALIZE_METHODS(BlockTransactions, obj)
std::vector< uint64_t > shorttxids
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
std::vector< PrefilledTransaction > prefilledtxn
SERIALIZE_METHODS(CBlockHeaderAndShortTxIDs, obj)
SERIALIZE_METHODS(BlockTransactionsRequest, obj)