Bitcoin Core 28.99.0
P2P Digital Currency
Functions
mp Namespace Reference

Functions to serialize / deserialize common bitcoin types. More...

Functions

template<typename LocalType , typename Value , typename Output >
requires Serializable<LocalType, DataStream> && std::is_same_v<LocalType, std::remove_cv_t<std::remove_reference_t<LocalType>>>
void CustomBuildField (TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output)
 Overload multiprocess library's CustomBuildField hook to allow any serializable object to be stored in a capnproto Data field or passed to a capnproto interface. More...
 
template<typename LocalType , typename Input , typename ReadDest >
requires Unserializable<LocalType, DataStream> && (!ipc::capnp::Deserializable<LocalType>)
decltype(auto) CustomReadField (TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest)
 Overload multiprocess library's CustomReadField hook to allow any object with an Unserialize method to be read from a capnproto Data field or returned from capnproto interface. More...
 
template<typename LocalType , typename Input , typename ReadDest >
requires ipc::capnp::Deserializable<LocalType>
decltype(auto) CustomReadField (TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest)
 Overload multiprocess library's CustomReadField hook to allow any object with a deserialize constructor to be read from a capnproto Data field or returned from capnproto interface. More...
 
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)
 Overload CustomBuildField and CustomReadField to serialize std::chrono parameters and return values as numbers. More...
 
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)
 
template<typename Value , typename Output >
void CustomBuildField (TypeList< UniValue >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output)
 Overload CustomBuildField and CustomReadField to serialize UniValue parameters and return values as JSON strings. More...
 
template<typename Input , typename ReadDest >
decltype(auto) CustomReadField (TypeList< UniValue >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest)
 
template<typename LocalType , typename Value , typename Output >
requires (std::is_same_v<decltype(output.get()), ::capnp::Data::Builder>) && (std::convertible_to<Value, std::span<const std::byte>> || std::convertible_to<Value, std::span<const char>> || std::convertible_to<Value, std::span<const unsigned char>> || std::convertible_to<Value, std::span<const signed char>>)
void CustomBuildField (TypeList< LocalType >, Priority< 2 >, InvokeContext &invoke_context, Value &&value, Output &&output)
 Generic ::capnp::Data field builder for any C++ type that can be converted to a span of bytes, like std::vector<char> or std::array<uint8_t>, or custom blob types like uint256 or PKHash with data() and size() methods pointing to bytes. More...
 
void CustomBuildMessage (InvokeContext &invoke_context, const BlockValidationState &src, ipc::capnp::messages::BlockValidationState::Builder &&builder)
 
void CustomReadMessage (InvokeContext &invoke_context, const ipc::capnp::messages::BlockValidationState::Reader &reader, BlockValidationState &dest)
 

Detailed Description

Functions to serialize / deserialize common bitcoin types.

Function Documentation

◆ CustomBuildField() [1/4]

template<typename LocalType , typename Value , typename Output >
requires Serializable<LocalType, DataStream> && std::is_same_v<LocalType, std::remove_cv_t<std::remove_reference_t<LocalType>>>
void mp::CustomBuildField ( TypeList< LocalType >  ,
Priority< 1 >  ,
InvokeContext &  invoke_context,
Value &&  value,
Output &&  output 
)

Overload multiprocess library's CustomBuildField hook to allow any serializable object to be stored in a capnproto Data field or passed to a capnproto interface.

Use Priority<1> so this hook has medium priority, and higher priority hooks could take precedence over this one.

Definition at line 50 of file common-types.h.

Here is the call graph for this function:

◆ CustomBuildField() [2/4]

template<typename LocalType , typename Value , typename Output >
requires (std::is_same_v<decltype(output.get()), ::capnp::Data::Builder>) && (std::convertible_to<Value, std::span<const std::byte>> || std::convertible_to<Value, std::span<const char>> || std::convertible_to<Value, std::span<const unsigned char>> || std::convertible_to<Value, std::span<const signed char>>)
void mp::CustomBuildField ( TypeList< LocalType >  ,
Priority< 2 >  ,
InvokeContext &  invoke_context,
Value &&  value,
Output &&  output 
)

Generic ::capnp::Data field builder for any C++ type that can be converted to a span of bytes, like std::vector<char> or std::array<uint8_t>, or custom blob types like uint256 or PKHash with data() and size() methods pointing to bytes.

Note: it might make sense to move this function into libmultiprocess, since it is fairly generic. However this would require decreasing its priority so it can be overridden, which would require more changes inside libmultiprocess to avoid conflicting with the Priority<1> CustomBuildField function it already provides for std::vector. Also, it might make sense to provide a CustomReadField counterpart to this function, which could be called to read C++ types that can be constructed from spans of bytes from ::capnp::Data fields. But so far there hasn't been a need for this.

Definition at line 151 of file common-types.h.

◆ CustomBuildField() [3/4]

template<class Rep , class Period , typename Value , typename Output >
void mp::CustomBuildField ( TypeList< std::chrono::duration< Rep, Period > >  ,
Priority< 1 >  ,
InvokeContext &  invoke_context,
Value &&  value,
Output &&  output 
)

Overload CustomBuildField and CustomReadField to serialize std::chrono parameters and return values as numbers.

Definition at line 100 of file common-types.h.

◆ CustomBuildField() [4/4]

template<typename Value , typename Output >
void mp::CustomBuildField ( TypeList< UniValue ,
Priority< 1 >  ,
InvokeContext &  invoke_context,
Value &&  value,
Output &&  output 
)

Overload CustomBuildField and CustomReadField to serialize UniValue parameters and return values as JSON strings.

Definition at line 120 of file common-types.h.

◆ CustomBuildMessage()

void mp::CustomBuildMessage ( InvokeContext &  invoke_context,
const BlockValidationState src,
ipc::capnp::messages::BlockValidationState::Builder &&  builder 
)

Definition at line 11 of file mining.cpp.

Here is the call graph for this function:

◆ CustomReadField() [1/4]

template<typename LocalType , typename Input , typename ReadDest >
requires Unserializable<LocalType, DataStream> && (!ipc::capnp::Deserializable<LocalType>)
decltype(auto) mp::CustomReadField ( TypeList< LocalType >  ,
Priority< 1 >  ,
InvokeContext &  invoke_context,
Input &&  input,
ReadDest &&  read_dest 
)

Overload multiprocess library's CustomReadField hook to allow any object with an Unserialize method to be read from a capnproto Data field or returned from capnproto interface.

Use Priority<1> so this hook has medium priority, and higher priority hooks could take precedence over this one.

Definition at line 70 of file common-types.h.

Here is the call graph for this function:

◆ CustomReadField() [2/4]

template<typename LocalType , typename Input , typename ReadDest >
requires ipc::capnp::Deserializable<LocalType>
decltype(auto) mp::CustomReadField ( TypeList< LocalType >  ,
Priority< 1 >  ,
InvokeContext &  invoke_context,
Input &&  input,
ReadDest &&  read_dest 
)

Overload multiprocess library's CustomReadField hook to allow any object with a deserialize constructor to be read from a capnproto Data field or returned from capnproto interface.

Use Priority<1> so this hook has medium priority, and higher priority hooks could take precedence over this one.

Definition at line 87 of file common-types.h.

Here is the call graph for this function:

◆ CustomReadField() [3/4]

template<class Rep , class Period , typename Input , typename ReadDest >
decltype(auto) mp::CustomReadField ( TypeList< std::chrono::duration< Rep, Period > >  ,
Priority< 1 >  ,
InvokeContext &  invoke_context,
Input &&  input,
ReadDest &&  read_dest 
)

Definition at line 111 of file common-types.h.

◆ CustomReadField() [4/4]

template<typename Input , typename ReadDest >
decltype(auto) mp::CustomReadField ( TypeList< UniValue ,
Priority< 1 >  ,
InvokeContext &  invoke_context,
Input &&  input,
ReadDest &&  read_dest 
)

Definition at line 128 of file common-types.h.

◆ CustomReadMessage()

void mp::CustomReadMessage ( InvokeContext &  invoke_context,
const ipc::capnp::messages::BlockValidationState::Reader &  reader,
BlockValidationState dest 
)

Definition at line 29 of file mining.cpp.

Here is the call graph for this function: