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

examples: implement support for passing accounts and copy_code #390

Merged
merged 6 commits into from
Oct 30, 2019

Conversation

axic
Copy link
Member

@axic axic commented Aug 8, 2019

Part of #334.

auto code = it->second.code;
if (code_offset >= code.size())
return 0;
// TODO: implement this more nicely?
Copy link
Member Author

Choose a reason for hiding this comment

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

@chfast do you want to clear this up? 😉

@axic axic force-pushed the example-host-lib branch 2 times, most recently from 244c478 to 44b2cd4 Compare August 8, 2019 17:30
Copy link
Member

@chfast chfast left a comment

Choose a reason for hiding this comment

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

std::advance(begin, static_cast<long>(code_offset));
auto len = std::distance(begin, end);
if (len > static_cast<long>(buffer_size))
std::advance(end, len - static_cast<long>(buffer_size));
Copy link
Member

Choose a reason for hiding this comment

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

This will advance it in the wrong direction (out of the vector). I think it is easier to use size instead of end in this case and in the end use std::copy_n().

auto it = accounts.find(addr);
if (it == accounts.end())
return 0;
auto code = it->second.code;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
auto code = it->second.code;
auto& code = it->second.code;

@chfast chfast merged commit 8eac504 into master Oct 30, 2019
@chfast chfast deleted the example-host-lib branch October 30, 2019 18:21
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.

2 participants