Skip to content

Commit

Permalink
multiprocess: Expand mining interface (part 2)
Browse files Browse the repository at this point in the history
Add interface changes from

bitcoin#30409
bitcoin#30440

This commit updates the Cap'n Proto Mining interface after updating the C++
Mining interface last commit.
  • Loading branch information
ryanofsky committed Jul 16, 2024
1 parent 05d42d5 commit 8a52ba5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ipc/capnp/common-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@ requires
auto result = output.init(data.size());
memcpy(result.begin(), data.data(), data.size());
}

//! Overload CustomBuildField and CustomReadField to serialize std::chrono
//! parameters and return values as numbers.
//! TODO: Could add compile time checks to make sure types are compatible and
//! precision is not lost.
template <class Rep, class Period, typename Value, typename Output>
void CustomBuildField(TypeList<std::chrono::duration<Rep, Period>>, Priority<1>, InvokeContext& invoke_context, Value&& value,
Output&& output)
{
output.set(value.count());
}

template <class Rep, class Period, typename Input, typename ReadDest>
decltype(auto) CustomReadField(TypeList<std::chrono::duration<Rep, Period>>, Priority<1>, InvokeContext& invoke_context,
Input&& input, ReadDest&& read_dest)
{
return read_dest.construct(input.get());
}
} // namespace mp

#endif // BITCOIN_IPC_CAPNP_COMMON_TYPES_H
26 changes: 26 additions & 0 deletions src/ipc/capnp/mining.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,29 @@ $Proxy.includeTypes("ipc/capnp/mining-types.h");
interface Mining $Proxy.wrap("interfaces::Mining") {
isTestChain @0 (context :Proxy.Context) -> (result: Bool);
isInitialBlockDownload @1 (context :Proxy.Context) -> (result: Bool);
<<<<<<< HEAD
getTip @2 (context :Proxy.Context) -> (result: Common.BlockRef, hasResult: Bool);
waitTipChanged @3 (context :Proxy.Context, currentTip: Data, timeout: Float64) -> (result: Common.BlockRef);
createNewBlock @4 (scriptPubKey: Data, options: BlockCreateOptions) -> (result: BlockTemplate);
processNewBlock @5 (context :Proxy.Context, block: Data) -> (newBlock: Bool, result: Bool);
getTransactionsUpdated @6 (context :Proxy.Context) -> (result: UInt32);
testBlockValidity @7 (context :Proxy.Context, block: Data, checkMerkleRoot: Bool) -> (state: BlockValidationState, result: Bool);
||||||| parent of 7b9aa0b6eb11 (multiprocess: Expand mining interface (part 2))
getTipHash @2 (context :Proxy.Context) -> (result: Data);
createNewBlock @3 (scriptPubKey: Data, options: BlockCreateOptions) -> (result: BlockTemplate);
processNewBlock @4 (context :Proxy.Context, block: Data) -> (newBlock: Bool, result: Bool);
getTransactionsUpdated @5 (context :Proxy.Context) -> (result: UInt32);
testBlockValidity @6 (context :Proxy.Context, block: Data, checkMerkleRoot: Bool) -> (state: BlockValidationState, result: Bool);
=======
getTipHash @2 (context :Proxy.Context) -> (result: Data);
createNewBlock @3 (scriptPubKey: Data, options: BlockCreateOptions) -> (result: BlockTemplate);
processNewBlock @4 (context :Proxy.Context, block: Data) -> (newBlock: Bool, result: Bool);
getTransactionsUpdated @5 (context :Proxy.Context) -> (result: UInt32);
testBlockValidity @6 (context :Proxy.Context, block: Data, checkMerkleRoot: Bool) -> (state: BlockValidationState, result: Bool);
getTipHeight @7 (context :Proxy.Context) -> (hasResult: Bool, result: Int32);
waitTipChanged @8 (timeout: Float64) -> (result: BlockInfo);
createNewBlock2 @9 (scriptPubKey: Data, options: BlockCreateOptions) -> (result: BlockTemplate);
>>>>>>> 7b9aa0b6eb11 (multiprocess: Expand mining interface (part 2))
}

interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {
Expand All @@ -39,9 +56,18 @@ struct BlockCreateOptions $Proxy.wrap("node::BlockCreateOptions") {
coinbaseOutputMaxAdditionalSigops @2 :UInt64 $Proxy.name("coinbase_output_max_additional_sigops");
}

<<<<<<< HEAD
# Note: serialization of the BlockValidationState C++ type is somewhat fragile
# and using the struct can be awkward. It would be good if testBlockValidity
# method were changed to return validity information in a simpler format.
||||||| parent of 7b9aa0b6eb11 (multiprocess: Expand mining interface (part 2))
=======
struct BlockInfo {
hash @0 :Data;
height @1 :Int32;
}

>>>>>>> 7b9aa0b6eb11 (multiprocess: Expand mining interface (part 2))
struct BlockValidationState {
mode @0 :Int32;
result @1 :Int32;
Expand Down

0 comments on commit 8a52ba5

Please sign in to comment.