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

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

Merged
merged 1 commit into from Nov 19, 2018

Conversation

Projects
4 participants
@cryptocode
Copy link
Collaborator

commented Nov 18, 2018

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 this to the V18.0 milestone Nov 19, 2018

@rkeene rkeene merged commit 84e3f0b into nanocurrency:master Nov 19, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@cryptocode cryptocode deleted the cryptocode:serialize-encapsulation branch Nov 19, 2018

@zhyatt zhyatt added this to Unscheduled in V18 Dec 27, 2018

@cryptocode cryptocode moved this from Unscheduled to CP 1 (2018-01-09) in V18 Dec 27, 2018

@cryptocode cryptocode moved this from CP 1 (2018-01-09) to Unscheduled in V18 Dec 28, 2018

@cryptocode cryptocode moved this from Unscheduled to CP 1 (2018-01-09) in V18 Dec 28, 2018

@cryptocode cryptocode moved this from CP 1 (2018-01-09) to CP 0 in V18 Dec 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.