Skip to content

Commit

Permalink
add block signature to compact blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
backpacker69 committed Mar 30, 2019
1 parent 9f6946e commit 2caf81a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/blockencodings.cpp
Expand Up @@ -17,7 +17,7 @@

CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block, bool fUseWTXID) :
nonce(GetRand(std::numeric_limits<uint64_t>::max())),
shorttxids(block.vtx.size() - 1), prefilledtxn(1), header(block) {
shorttxids(block.vtx.size() - 1), prefilledtxn(1), header(block), vchBlockSig(block.vchBlockSig) {
FillShortTxIDSelector();
//TODO: Use our mempool prior to block acceptance to predictively fill more than just the coinbase
prefilledtxn[0] = {0, block.vtx[0]};
Expand Down Expand Up @@ -53,6 +53,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c

assert(header.IsNull() && txn_available.empty());
header = cmpctblock.header;
vchBlockSig = cmpctblock.vchBlockSig;
txn_available.resize(cmpctblock.BlockTxCount());

int32_t lastprefilledindex = -1;
Expand Down Expand Up @@ -177,6 +178,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
assert(!header.IsNull());
uint256 hash = header.GetHash();
block = header;
block.vchBlockSig = vchBlockSig;
block.vtx.resize(txn_available.size());

size_t tx_missing_offset = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/blockencodings.h
Expand Up @@ -144,6 +144,7 @@ class CBlockHeaderAndShortTxIDs {

public:
CBlockHeader header;
std::vector<unsigned char> vchBlockSig;

// Dummy for deserialization
CBlockHeaderAndShortTxIDs() {}
Expand All @@ -160,7 +161,7 @@ class CBlockHeaderAndShortTxIDs {
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(header);
READWRITE(nonce);

READWRITE(vchBlockSig);
uint64_t shorttxids_size = (uint64_t)shorttxids.size();
READWRITE(COMPACTSIZE(shorttxids_size));
if (ser_action.ForRead()) {
Expand Down Expand Up @@ -198,6 +199,7 @@ class PartiallyDownloadedBlock {
CTxMemPool* pool;
public:
CBlockHeader header;
std::vector<unsigned char> vchBlockSig;
explicit PartiallyDownloadedBlock(CTxMemPool* poolIn) : pool(poolIn) {}

// extra_txn is a list of extra transactions to look at, in <witness hash, reference> form
Expand Down

0 comments on commit 2caf81a

Please sign in to comment.