From 5c5d0b62648e1b144b7b93c199f45265dac100e5 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Thu, 10 Dec 2020 13:31:48 -0500 Subject: Add FoundBlock.found member This change lets IPC serialization code handle FoundBlock arguments more simply and efficiently. Without this change there was no way to determine from a FoundBlock object whether a block was found or not. So in order to correctly implement behavior of leaving FoundBlock output variables unmodified when a block was not found, IPC code would have to read preexisting output variable values from the local process, send them to the remote process, receive output values back from the remote process, and save them to output variables unconditionally. With FoundBlock.found method, the process is simpler. There's no need to read or send preexisting local output variable values, just to read final output values from the remote process and set them conditionally if the block was found. --- src/interfaces/chain.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/interfaces') diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 3395741b1b..d40bd09e2d 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -35,7 +35,9 @@ namespace interfaces { class Handler; class Wallet; -//! Helper for findBlock to selectively return pieces of block data. +//! Helper for findBlock to selectively return pieces of block data. If block is +//! found, data will be returned by setting specified output variables. If block +//! is not found, output variables will keep their previous values. class FoundBlock { public: @@ -60,6 +62,7 @@ public: bool* m_in_active_chain = nullptr; const FoundBlock* m_next_block = nullptr; CBlock* m_data = nullptr; + mutable bool found = false; }; //! Interface giving clients (wallet processes, maybe other analysis tools in -- cgit v1.2.3