aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2020-01-23 21:34:58 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2020-05-23 20:02:10 -0300
commita06e845e826acaeb0db7cf02b2519c177e94dee5 (patch)
tree6eeaf01a99b90382adb98d79500f1d8ea40285f0 /src/interfaces
parent2f867203b0c7a4438ce484be4cfa2b29dbf1abf0 (diff)
downloadbitcoin-a06e845e826acaeb0db7cf02b2519c177e94dee5.tar.xz
BlockTip struct created and connected to notifyHeaderTip and notifyBlockTip signals.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/node.cpp4
-rw-r--r--src/interfaces/node.h12
2 files changed, 12 insertions, 4 deletions
diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp
index 582bf68ff8..ca1435fe60 100644
--- a/src/interfaces/node.cpp
+++ b/src/interfaces/node.cpp
@@ -315,7 +315,7 @@ public:
std::unique_ptr<Handler> handleNotifyBlockTip(NotifyBlockTipFn fn) override
{
return MakeHandler(::uiInterface.NotifyBlockTip_connect([fn](SynchronizationState sync_state, const CBlockIndex* block) {
- fn(sync_state, block->GetBlockHash(), block->nHeight, block->GetBlockTime(),
+ fn(sync_state, BlockTip{block->nHeight, block->GetBlockTime(), block->GetBlockHash()},
GuessVerificationProgress(Params().TxData(), block));
}));
}
@@ -323,7 +323,7 @@ public:
{
return MakeHandler(
::uiInterface.NotifyHeaderTip_connect([fn](SynchronizationState sync_state, const CBlockIndex* block) {
- fn(sync_state, block->GetBlockHash(), block->nHeight, block->GetBlockTime(),
+ fn(sync_state, BlockTip{block->nHeight, block->GetBlockTime(), block->GetBlockHash()},
/* verification progress is unused when a header was received */ 0);
}));
}
diff --git a/src/interfaces/node.h b/src/interfaces/node.h
index e4df908847..0b7fb6736a 100644
--- a/src/interfaces/node.h
+++ b/src/interfaces/node.h
@@ -36,6 +36,7 @@ struct bilingual_str;
namespace interfaces {
class Handler;
class Wallet;
+struct BlockTip;
//! Top-level interface for a bitcoin node (bitcoind process).
class Node
@@ -253,12 +254,12 @@ public:
//! Register handler for block tip messages.
using NotifyBlockTipFn =
- std::function<void(SynchronizationState, const uint256& block_hash, int height, int64_t block_time, double verification_progress)>;
+ std::function<void(SynchronizationState, interfaces::BlockTip tip, double verification_progress)>;
virtual std::unique_ptr<Handler> handleNotifyBlockTip(NotifyBlockTipFn fn) = 0;
//! Register handler for header tip messages.
using NotifyHeaderTipFn =
- std::function<void(SynchronizationState, const uint256& block_hash, int height, int64_t block_time, double verification_progress)>;
+ std::function<void(SynchronizationState, interfaces::BlockTip tip, double verification_progress)>;
virtual std::unique_ptr<Handler> handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0;
//! Return pointer to internal chain interface, useful for testing.
@@ -268,6 +269,13 @@ public:
//! Return implementation of Node interface.
std::unique_ptr<Node> MakeNode();
+//! Block tip (could be a header or not, depends on the subscribed signal).
+struct BlockTip {
+ int block_height;
+ int64_t block_time;
+ uint256 block_hash;
+};
+
} // namespace interfaces
#endif // BITCOIN_INTERFACES_NODE_H