-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Addressing binary serialization for db types #966
Conversation
enacted: Vec<H256>, | ||
/// Hashes of the blocks which were invalidated. | ||
retracted: Vec<H256>, | ||
BranchBecomingCanonChain(BranchBecomingCanonChainData), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Member struct can't be used for IPC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to move it to seraparate struct BranchBecomingCanonChainData
to represent it later as a tuple to use in generic serializer
impl<'a, V1, V2, T3> ToBytesWithMap for (&'a Vec<V1>, &'a Vec<V2>, &'a T3)
otherwise you need to write full serialization for the whole struct BlockLocation
by hand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the struct's serialisation code not be autogenerated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gavofyork yes, one can provide custom implementation of ToBytesWithMap & FromRawBytesVariable, but you will have to do it for the whole struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one can provide custom implementation
can this "custom implementation" not be autogenerated by the compiler plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gavofyork
yes this is possible, but it will take some time and will be targeted by future prs
the idea is to generate code that will write/read structs directly to/from nanomsg buffers and to achieve zero-copy messaging
and this is kind of temporal solution
Consider using ElasticArray instead of |
for interprocess messages, all arguments types must support
FromRawBytesVariable
andToBytesWithMap
traitssimple fixed-size structs are auto-implemented with
sized_binary_map!
macro, while structures containing heap-allocated vectors of data need to stick to several pre-mapped tuples