Skip to content

Commit 5c5d0b6

Browse files
committed
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.
1 parent 1704bbf commit 5c5d0b6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/interfaces/chain.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ namespace interfaces {
3535
class Handler;
3636
class Wallet;
3737

38-
//! Helper for findBlock to selectively return pieces of block data.
38+
//! Helper for findBlock to selectively return pieces of block data. If block is
39+
//! found, data will be returned by setting specified output variables. If block
40+
//! is not found, output variables will keep their previous values.
3941
class FoundBlock
4042
{
4143
public:
@@ -60,6 +62,7 @@ class FoundBlock
6062
bool* m_in_active_chain = nullptr;
6163
const FoundBlock* m_next_block = nullptr;
6264
CBlock* m_data = nullptr;
65+
mutable bool found = false;
6366
};
6467

6568
//! Interface giving clients (wallet processes, maybe other analysis tools in

src/node/interfaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<Rec
345345
REVERSE_LOCK(lock);
346346
if (!ReadBlockFromDisk(*block.m_data, index, Params().GetConsensus())) block.m_data->SetNull();
347347
}
348+
block.found = true;
348349
return true;
349350
}
350351

0 commit comments

Comments
 (0)