5 #ifndef BITCOIN_BLOCKENCODINGS_H 6 #define BITCOIN_BLOCKENCODINGS_H 21 template <
typename Stream,
typename I>
void Ser(Stream &s, I v) {
22 if (v < m_shift || v >= std::numeric_limits<uint64_t>::max()) {
23 throw std::ios_base::failure(
"differential value overflow");
26 m_shift = uint64_t(v) + 1;
28 template <
typename Stream,
typename I>
void Unser(Stream &s, I &v) {
31 if (m_shift < n || m_shift >= std::numeric_limits<uint64_t>::max() ||
32 m_shift < std::numeric_limits<I>::min() ||
33 m_shift > std::numeric_limits<I>::max()) {
34 throw std::ios_base::failure(
"differential value overflow");
56 std::vector<CTransactionRef>
txn;
60 : blockhash(req.blockhash), txn(req.indices.size()) {}
78 Using<TransactionCompression>(obj.tx));
98 void FillShortTxIDSelector()
const;
102 static const int SHORTTXIDS_LENGTH = 6;
116 uint64_t GetShortID(
const TxHash &txhash)
const;
119 return shorttxids.size() + prefilledtxn.size();
124 obj.header, obj.nonce,
128 if (ser_action.ForRead()) {
129 if (obj.BlockTxCount() > std::numeric_limits<uint32_t>::max()) {
130 throw std::ios_base::failure(
"indices overflowed 32 bits");
132 obj.FillShortTxIDSelector();
140 size_t prefilled_count = 0, mempool_count = 0, extra_count = 0;
147 : pool(poolIn), config(&configIn) {}
153 const std::vector<std::pair<TxHash, CTransactionRef>> &extra_txn);
154 bool IsTxAvailable(
size_t index)
const;
156 const std::vector<CTransactionRef> &vtx_missing);
159 #endif // BITCOIN_BLOCKENCODINGS_H std::shared_ptr< const CTransaction > CTransactionRef
enum ReadStatus_t ReadStatus
CBlockHeaderAndShortTxIDs()
std::vector< CTransactionRef > txns_available
uint64_t ReadCompactSize(Stream &is)
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
PartiallyDownloadedBlock(const Config &configIn, CTxMemPool *poolIn)
BlockTransactions(const BlockTransactionsRequest &req)
SERIALIZE_METHODS(PrefilledTransaction, obj)
std::vector< CTransactionRef > txn
SERIALIZE_METHODS(BlockTransactions, obj)
A TxHash is the double sha256 hash of the full transaction data.
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
A BlockHash is a unqiue identifier for a block.
SERIALIZE_METHODS(CBlockHeaderAndShortTxIDs, obj)
std::vector< uint32_t > indices
static Wrapper< Formatter, T & > Using(T &&t)
Cause serialization/deserialization of an object to be done using a specified formatter class...
size_t BlockTxCount() const
SERIALIZE_METHODS(BlockTransactionsRequest, obj)