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

Helpers for ease of use #19

Open
Cafe137 opened this issue Sep 1, 2021 · 1 comment
Open

Helpers for ease of use #19

Cafe137 opened this issue Sep 1, 2021 · 1 comment
Labels

Comments

@Cafe137
Copy link
Contributor

Cafe137 commented Sep 1, 2021

Some functionality I could not find in the library, but would help adaptation IMO.

fork.path - I am currently prepending the prefixes of forks, in order to get full paths in the end. Maybe this could be done during load by the library and provide it as a string or Uint8Array on Fork

findAllValueForks - For a given node, collect all value Forks, so user space code does not have to recursively walk through the forks and filter them.

addFork and removePath - could accept string | Uint8Array instead of Uint8Array only, so the user space code does not need to apply new TextEncoder().encode(path) for all the calls. Similarly, reference could accept string too, assumed to be a hex representation of 32 or 64 bytes data.

@bee-runner bee-runner bot added the issue label Sep 1, 2021
@Cafe137 Cafe137 changed the title Helpers: findAllValueForks and fork.path Helpers for ease of use Sep 1, 2021
@nugaon
Copy link
Member

nugaon commented Sep 1, 2021

fork.path - I am currently prepending the prefixes of forks, in order to get full paths in the end. Maybe this could be done during load by the library and provide it as a string or Uint8Array on Fork

I would rather create a separate utility function or abstraction for this feature, but surely I wouldn't put any additional property to the mantaray fork or node which is related to the trie structure. I'm saying this because many cases you want to move fork/node to one place to another and you shouldn't maintain/update these additional meta-properties during these kind of processes.

findAllValueForks - For a given node, collect all value Forks, so user space code does not have to recursively walk through the forks and filter them.

good idea : )

addFork and removePath - could accept string | Uint8Array instead of Uint8Array only, so the user space code does not need to apply new TextEncoder().encode(path) for all the calls. Similarly, reference could accept string too, assumed to be a hex representation of 32 or 64 bytes data.

I think this convenient feature is justified to be added and with it little bit diverge from the reference implementation's interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants