MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / addTransaction

Method addTransaction

src/thinblockbuilder.cpp:32–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32ThinBlockBuilder::TXAddRes ThinBlockBuilder::addTransaction(const CTransaction& tx) {
33 assert(!tx.IsNull());
34
35 auto loc = std::find_if(wantedTxs.begin(), wantedTxs.end(), [&tx](const ThinTx& b) {
36 return b.equals(tx.GetHash());
37 });
38
39 if (loc == wantedTxs.end()){
40 // TX does not belong to block
41 return TX_UNWANTED;
42 }
43
44 size_t offset = std::distance(wantedTxs.begin(), loc);
45
46 if (!thinBlock.vtx[offset].IsNull()) {
47 // We already have this one.
48 return TX_DUP;
49 }
50
51 thinBlock.vtx[offset] = tx;
52 missing--;
53 return TX_ADDED;
54}
55
56int ThinBlockBuilder::numTxsMissing() const {
57 return missing;

Callers 3

buildStubMethod · 0.80
addTxMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 5

equalsMethod · 0.80
IsNullMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetHashMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64