Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Addressing binary serialization for db types #966

Merged
merged 9 commits into from
Apr 20, 2016
Merged

Conversation

NikVolf
Copy link
Contributor

@NikVolf NikVolf commented Apr 17, 2016

for interprocess messages, all arguments types must support FromRawBytesVariable and ToBytesWithMap traits

simple 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

@NikVolf NikVolf added the A0-pleasereview 🤓 Pull request needs code review. label Apr 17, 2016
enacted: Vec<H256>,
/// Hashes of the blocks which were invalidated.
retracted: Vec<H256>,
BranchBecomingCanonChain(BranchBecomingCanonChainData),
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

@NikVolf NikVolf Apr 18, 2016

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

Copy link
Contributor

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?

Copy link
Contributor Author

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

@arkpar
Copy link
Collaborator

arkpar commented Apr 18, 2016

Consider using ElasticArray instead of Vec<u8> for serialization

@arkpar arkpar added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Apr 18, 2016
@arkpar arkpar merged commit e47af7f into master Apr 20, 2016
@NikVolf NikVolf deleted the from-bytes-extend branch April 28, 2016 12:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants