diff options
| author | Riccardo Spagni <ric@spagni.net> | 2017-03-23 11:46:57 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2017-03-23 11:46:57 +0200 |
| commit | a73a886cb16c42a57d10c93e50eb4f84d965c124 (patch) | |
| tree | 0df8bbd20301d53613b07493940417c70ccf7c4e /src/cryptonote_basic/cryptonote_basic.h | |
| parent | 7432f13898766085117f57557c94035dfdcb65c6 (diff) | |
| parent | 91d410902399befd81589fd0153e5b7994bcdaa2 (diff) | |
| download | monzero-core-a73a886cb16c42a57d10c93e50eb4f84d965c124.tar.gz monzero-core-a73a886cb16c42a57d10c93e50eb4f84d965c124.tar.xz monzero-core-a73a886cb16c42a57d10c93e50eb4f84d965c124.zip | |
Merge pull request #1911
91d41090 tx_pool: ensure txes loaded from poolstate.bin have their txid cached (moneromooo-monero)
aaeb164c tx_pool: remove transactions if they're in the blockchain (moneromooo-monero)
558cfc31 core, wallet: faster tx pool scanning (moneromooo-monero)
f065234b core: cache tx and block hashes in the respective classes (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_basic/cryptonote_basic.h')
| -rw-r--r-- | src/cryptonote_basic/cryptonote_basic.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/cryptonote_basic/cryptonote_basic.h b/src/cryptonote_basic/cryptonote_basic.h index ed2787cf7..3492ace2b 100644 --- a/src/cryptonote_basic/cryptonote_basic.h +++ b/src/cryptonote_basic/cryptonote_basic.h @@ -190,11 +190,24 @@ namespace cryptonote std::vector<std::vector<crypto::signature> > signatures; //count signatures always the same as inputs count rct::rctSig rct_signatures; + // hash cash + mutable crypto::hash hash; + mutable size_t blob_size; + mutable bool hash_valid; + mutable bool blob_size_valid; + transaction(); virtual ~transaction(); void set_null(); + void invalidate_hashes(); BEGIN_SERIALIZE_OBJECT() + if (!typename Archive<W>::is_saving()) + { + hash_valid = false; + blob_size_valid = false; + } + FIELDS(*static_cast<transaction_prefix *>(this)) if (version == 1) @@ -299,6 +312,15 @@ namespace cryptonote extra.clear(); signatures.clear(); rct_signatures.type = rct::RCTTypeNull; + hash_valid = false; + blob_size_valid = false; + } + + inline + void transaction::invalidate_hashes() + { + hash_valid = false; + blob_size_valid = false; } inline @@ -339,10 +361,20 @@ namespace cryptonote struct block: public block_header { + block(): block_header(), hash_valid(false) {} + void invalidate_hashes() { hash_valid = false; } + transaction miner_tx; std::vector<crypto::hash> tx_hashes; + // hash cash + mutable crypto::hash hash; + mutable bool hash_valid; + BEGIN_SERIALIZE_OBJECT() + if (!typename Archive<W>::is_saving()) + hash_valid = false; + FIELDS(*static_cast<block_header *>(this)) FIELD(miner_tx) FIELD(tx_hashes) |
