Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message improvements #48

Closed
wants to merge 6 commits into from
Closed

Message improvements #48

wants to merge 6 commits into from

Conversation

altonen
Copy link
Contributor

@altonen altonen commented Dec 14, 2021

Use procedural macros to implement a new derive attribute called Message which is used to auto-generate helper functions that are going to be common for all messages types. This will significantly reduce the amount of code needed for different message types

p2p/src/util/src/lib.rs Show resolved Hide resolved
p2p/src/message.rs Outdated Show resolved Hide resolved
p2p/src/message.rs Outdated Show resolved Hide resolved
p2p/src/util/src/lib.rs Outdated Show resolved Hide resolved
p2p/src/util/src/lib.rs Outdated Show resolved Hide resolved
p2p/src/util/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@TheQuantumPhysicist TheQuantumPhysicist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is all my comments for now.

common/Cargo.toml Outdated Show resolved Hide resolved
p2p/src/message.rs Show resolved Hide resolved
p2p/src/message.rs Show resolved Hide resolved
This macro adds helper functionality for Mintlayer message.
Currently it includes new(), into_msg() and from_msg() functions
so if a peer wants to send/recv a Hello message, they only need to call:

socket.send(Hello::new(..).into_msg()).unwrap();
let hello = socket.recv().unwrap().from_msg().unwrap();

and they only need to give the struct specification, the code for
these functions is generated automatically.
The latter doens't implement PartialEq which makes writing tests
harder. ErrorKind already contains all of the information
P2P might be interested in so it makes more sense to use that.
@altonen altonen force-pushed the msg-format branch 2 times, most recently from d735bc1 to c001a8c Compare December 15, 2021 09:21
This is to make messages network-agnostic and keep the interface
of each message clean as they don't really care what network is in
use when they are being created.

Saving the chain config to a lazily evaluated static variable allows
the chain config data to be specified at the start-up but also allows
different subsystems to use the values as if they were static variables.
@altonen
Copy link
Contributor Author

altonen commented Dec 15, 2021

I'll close this, the new implementation is not able to use the code written for this message format

@altonen altonen closed this Dec 15, 2021
@altonen altonen deleted the msg-format branch January 6, 2022 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants