Skip to content
New issue

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

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

Already on GitHub? # to your account

Move serialization to vector pattern into a base class function #1386

Merged
merged 1 commit into from
Nov 19, 2018

Conversation

cryptocode
Copy link
Contributor

Turns this recurring pattern:

rai::confirm_req message (block);
std::shared_ptr<std::vector<uint8_t>> bytes (new std::vector<uint8_t>);
{
	rai::vectorstream stream (*bytes);
	message.serialize (stream);
}

into:

rai::confirm_req message (block);
auto bytes = message.to_bytes ();

Sometimes to_bytes () can be used directly in parameter position, simplifying the code further.

To make this work in const contexts, serialize functions are now const

@rkeene rkeene added the quality improvements This item indicates the need for or supplies changes that improve maintainability label Nov 19, 2018
@rkeene rkeene added this to the V18.0 milestone Nov 19, 2018
@rkeene rkeene merged commit 84e3f0b into nanocurrency:master Nov 19, 2018
@cryptocode cryptocode deleted the serialize-encapsulation branch November 19, 2018 22:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
quality improvements This item indicates the need for or supplies changes that improve maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants