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

Create an API for calculating the number bytes and shares used by compact and sparse data #700

Closed
evan-forbes opened this issue Sep 12, 2022 · 1 comment

Comments

@evan-forbes
Copy link
Member

evan-forbes commented Sep 12, 2022

As pointed out in this comment and this comment, it will be easier to maintain and modify share encoding code if we also have a canonical API for calculating the number bytes and shares that compact and sparse share use. There are many different uses of this estimation logic, so getting a perfect API or modifying the existing code to use such an API could take a few PRs. We should track them here.

@rootulp
Copy link
Collaborator

rootulp commented Feb 3, 2023

We now have the following exported functions which handle the number of shares usecase:

// SparseSharesNeeded returns the number of shares needed to store a sequence of
// length sequenceLen.
func SparseSharesNeeded(sequenceLen uint32) (sharesNeeded int) {
// CompactSharesNeeded returns the number of compact shares needed to store a
// sequence of length sequenceLen. The parameter sequenceLen is the number
// of bytes of transactions or intermediate state roots in a sequence.
func CompactSharesNeeded(sequenceLen int) (sharesNeeded int) {

I don't see an immediate need for a separate API that returns number of bytes but it would be easy to implement (number of shares needed * share size) so proposal to mark this as resolved for now? @evan-forbes

@github-project-automation github-project-automation bot moved this from TODO to Done in Celestia Node Feb 3, 2023
@rootulp rootulp removed this from Celestia Node Feb 3, 2023
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

No branches or pull requests

2 participants