forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Txs To Shares Roundtrip (cosmos#889)
Adds ability to: - Convert `TxWithISRs` to Shares - Convert Shares to byte array (that will be posted on celestia) - Convert above byte array back to Shares - Convert Shares back to `TxWithISRs` - Parse Out of Context Shares Adds relevant roundtrip tests Resolves cosmos#881 Resolves cosmos#934 Resolves cosmos#886 Resolves cosmos#925 Note: All shares are written and interpreted as compact shares so they contain reserved bytes (see https://celestiaorg.github.io/celestia-app/specs/data_structures.html#compact-share) Related PR in `celestia-app`: celestiaorg/celestia-app#1770
- Loading branch information
1 parent
1ed7f75
commit 70603f1
Showing
10 changed files
with
446 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package shares | ||
|
||
// Range is an end exclusive set of share indexes. | ||
type Range struct { | ||
// Start is the index of the first share occupied by this range. | ||
Start int | ||
// End is the next index after the last share occupied by this range. | ||
End int | ||
} | ||
|
||
func NewRange(start, end int) Range { | ||
return Range{Start: start, End: end} | ||
} | ||
|
||
func EmptyRange() Range { | ||
return Range{Start: 0, End: 0} | ||
} | ||
|
||
func (r Range) IsEmpty() bool { | ||
return r.Start == 0 && r.End == 0 | ||
} | ||
|
||
func (r *Range) Add(value int) { | ||
r.Start += value | ||
r.End += value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.