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

Refactoring: Push(namespace.PrefixedData)->Push(namespace.ID, []byte) #56

Closed
wants to merge 1 commit into from

Conversation

liamsi
Copy link
Member

@liamsi liamsi commented May 5, 2022

for details see: #55 (particularly: #55 (comment))

closes: #55

@codecov
Copy link

codecov bot commented May 5, 2022

Codecov Report

Merging #56 (c1fbf91) into master (b43d67c) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #56      +/-   ##
==========================================
- Coverage   95.56%   95.54%   -0.03%     
==========================================
  Files           7        6       -1     
  Lines         361      359       -2     
==========================================
- Hits          345      343       -2     
  Misses         11       11              
  Partials        5        5              
Impacted Files Coverage Δ
namespace/id.go 100.00% <ø> (ø)
nmt.go 93.28% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b43d67c...c1fbf91. Read the comment docs.

@liamsi
Copy link
Member Author

liamsi commented May 5, 2022

Note that due to the copy: https://github.com/celestiaorg/nmt/pull/56/checks?check_run_id=6312183477
image

But also we do this copy in the wrapper now which can be removed. So it should be the same net alloc.

@adlerjohn adlerjohn added the enhancement New feature or request label May 5, 2022
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

LGTM 👍

everytime I come to this repo, I'm always impressed with the test coverage and benchmarks etc. @liamsi 's work a long time ago is still paying dividends

also, one day we will stop changing the API for Push lolol

Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

@liamsi, One mid-level thing. We shouldn't pass the visitor the result of the append of nid+data and data only, or we should pass both as separate params as well.

Or just rework Visitor API completely, as we discussed 😅

@liamsi
Copy link
Member Author

liamsi commented May 10, 2022

or we should pass both as separate params as well.

Yeah, that is what I thought as well but after we chatted about it it seemed not necessary and I didn't think about it further. Can you open an issue with the proposed method signature? I'll do a quick follow-up PR in the next few days.

@liamsi
Copy link
Member Author

liamsi commented May 10, 2022

@Wondertan or should we hold off merging this as it is kinda useless without also changing the visitor?
Let me know what you have in mind and I can change it in here directly as well. Current visitor function signature is:

nmt/nmt.go

Line 22 in c1fbf91

type NodeVisitorFn = func(hash []byte, children ...[]byte)

and it's used here:

nmt/nmt.go

Line 295 in c1fbf91

n.visit(leafHash, n.leaves[start])

and here:

nmt/nmt.go

Line 302 in c1fbf91

n.visit(hash, left, right)

Am I understanding you correctly that you basically need it instead to be
n.visit(leafHash, n.leaves[start][:NamespaceLen], n.leaves[start][NamespaceLen:])
and
n.visit(hash, left[:NamespaceLen], left[NamespaceLen:], right[:NamespaceLen], right[NamespaceLen:])
(not exactly like the above but sth along these lines?)

@liamsi
Copy link
Member Author

liamsi commented May 13, 2022

actually closing this until we figure out how the Visitor API should be changed or if we want to get rid of it etc

@liamsi liamsi closed this May 13, 2022
@liamsi
Copy link
Member Author

liamsi commented May 13, 2022

I'll leave the branch around for a while though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

api: Push for data/shares with decoupled namespace
4 participants