datrs / merkle-tree-stream

A stream that generates a merkle tree based on the incoming data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Internalize external `roots` argument in initializer

yoshuawuyts opened this issue · comments

commented

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.