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

Internalize external roots argument in initializer #19

Open
yoshuawuyts opened this issue Nov 2, 2018 · 0 comments
Open

Internalize external roots argument in initializer #19

yoshuawuyts opened this issue Nov 2, 2018 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@yoshuawuyts
Copy link
Collaborator

Feature Request

Summary

Change

pub fn new(handler: H, roots: Vec<Rc<H::Node>>) -> MerkleTreeStream<H>

to

pub fn new(handler: H) -> MerkleTreeStream<H>

Motivation

The current API feels rather leaky at the moment, and is currently trading lowered memory usage for extra access costs on every access of the Merkle tree.

Instead by duplicating the nodes (using copy) and using an internal slab allocator, we could improve overall performance, clean up the API, at the cost of negligable extra memory cost.

Expected Behavior

Tell us how the feature should work. Explain the feature largely in terms of
examples.

Drawbacks

We'd be relying on internalized allocation, which might bite us in future for FFI. On the other hand: if we only require allocations to happen for data that crosses the FFI boundary, we don't need to worry here as this is very much internal. I think at least.

Worst case we can expose an additional API once we get to an FFI layer.

Rationale and alternatives

Alternatively we could leave the current API as-is, but it feels a bit messy, and is weird to use.

Unresolved Questions

None.

@yoshuawuyts yoshuawuyts added the help wanted Extra attention is needed label Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant