Add time methods to the Chain interface

And use them to remove uses of chainActive and mapBlockIndex in wallet code

This commit does not change behavior.

Co-authored-by: Ben Woosley <ben.woosley@gmail.com>
This commit is contained in:
Russell Yanofsky
2019-01-07 22:35:47 -08:00
parent 700c42b85d
commit d93c4c1d6e
5 changed files with 43 additions and 17 deletions

View File

@@ -333,8 +333,13 @@ public:
if (mi == m_wallet.mapWallet.end()) {
return false;
}
num_blocks = locked_chain->getHeight().value_or(-1);
block_time = ::chainActive.Tip()->GetBlockTime();
if (Optional<int> height = locked_chain->getHeight()) {
num_blocks = *height;
block_time = locked_chain->getBlockTime(*height);
} else {
num_blocks = -1;
block_time = -1;
}
tx_status = MakeWalletTxStatus(*locked_chain, mi->second);
return true;
}