5 #ifndef FABCOIN_BLOCK_ENCODINGS_H 6 #define FABCOIN_BLOCK_ENCODINGS_H 23 template <
typename Stream,
typename Operation>
37 template <
typename Stream,
typename Operation>
40 uint64_t indexes_size = (uint64_t)indexes.size();
42 if (ser_action.ForRead()) {
44 while (indexes.size() < indexes_size) {
45 indexes.resize(
std::min((uint64_t)(1000 + indexes.size()), indexes_size));
46 for (; i < indexes.size(); i++) {
50 throw std::ios_base::failure(
"index overflowed 16 bits");
56 for (
size_t j = 0; j < indexes.size(); j++) {
58 throw std::ios_base::failure(
"indexes overflowed 16 bits");
59 indexes[j] = indexes[j] + offset;
60 offset = indexes[j] + 1;
63 for (
size_t i = 0; i < indexes.size(); i++) {
64 uint64_t index = indexes[i] - (i == 0 ? 0 : (indexes[i - 1] + 1));
75 std::vector<CTransactionRef>
txn;
79 blockhash(req.blockhash), txn(req.indexes.
size()) {}
83 template <
typename Stream,
typename Operation>
86 uint64_t txn_size = (uint64_t)txn.size();
88 if (ser_action.ForRead()) {
90 while (txn.size() < txn_size) {
91 txn.resize(
std::min((uint64_t)(1000 + txn.size()), txn_size));
92 for (; i < txn.size(); i++)
96 for (
size_t i = 0; i < txn.size(); i++)
111 template <
typename Stream,
typename Operation>
113 uint64_t idx = index;
116 throw std::ios_base::failure(
"index overflowed 16-bits");
136 void FillShortTxIDSelector()
const;
140 static const int SHORTTXIDS_LENGTH = 6;
153 uint64_t GetShortID(
const uint256& txhash)
const;
155 size_t BlockTxCount()
const {
return shorttxids.size() + prefilledtxn.size(); }
159 template <
typename Stream,
typename Operation>
164 uint64_t shorttxids_size = (uint64_t)shorttxids.size();
166 if (ser_action.ForRead()) {
168 while (shorttxids.size() < shorttxids_size) {
169 shorttxids.resize(
std::min((uint64_t)(1000 + shorttxids.size()), shorttxids_size));
170 for (; i < shorttxids.size(); i++) {
171 uint32_t lsb = 0; uint16_t msb = 0;
174 shorttxids[i] = (uint64_t(msb) << 32) | uint64_t(lsb);
175 static_assert(SHORTTXIDS_LENGTH == 6,
"shorttxids serialization assumes 6-byte shorttxids");
179 for (
size_t i = 0; i < shorttxids.size(); i++) {
180 uint32_t lsb = shorttxids[i] & 0xffffffff;
181 uint16_t msb = (shorttxids[i] >> 32) & 0xffff;
189 if (ser_action.ForRead())
190 FillShortTxIDSelector();
197 size_t prefilled_count = 0, mempool_count = 0, extra_count = 0;
205 bool IsTxAvailable(
size_t index)
const;
206 ReadStatus FillBlock(
CBlock& block,
const std::vector<CTransactionRef>& vtx_missing);
enum ReadStatus_t ReadStatus
CBlockHeaderAndShortTxIDs()
size_t BlockTxCount() const
std::vector< uint16_t > indexes
std::vector< CTransactionRef > txn_available
BlockTransactions(const BlockTransactionsRequest &req)
PartiallyDownloadedBlock(CTxMemPool *poolIn)
std::shared_ptr< const CTransaction > CTransactionRef
void SerializationOp(Stream &s, Operation ser_action)
TransactionCompressor(CTransactionRef &txIn)
std::vector< CTransactionRef > txn
void SerializationOp(Stream &s, Operation ser_action)
void SerializationOp(Stream &s, Operation ser_action)
void SerializationOp(Stream &s, Operation ser_action)
void SerializationOp(Stream &s, Operation ser_action)
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
uint8_t const size_t const size
T & REF(const T &val)
Used to bypass the rule against non-const reference to temporary where it makes sense with wrappers s...