Skip to content

Commit

Permalink
docs: document data root tuple hex representation padding (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id authored Apr 17, 2023
1 parent e0fce1b commit 0b55683
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rpc/core/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ func padBytes(byt []byte, length int) ([]byte, error) {
// https://github.com/celestiaorg/quantum-gravity-bridge/blob/master/src/DataRootTuple.sol
func EncodeDataRootTuple(height uint64, dataRoot [32]byte) ([]byte, error) {
hexRepresentation := strconv.FormatUint(height, 16)
// Make sure hex representation has even length
// Make sure hex representation has even length.
// The `strconv.FormatUint` can return odd length hex encodings.
// For example, `strconv.FormatUint(10, 16)` returns `a`.
// Thus, we need to pad it.
if len(hexRepresentation)%2 == 1 {
hexRepresentation = "0" + hexRepresentation
}
Expand Down

0 comments on commit 0b55683

Please sign in to comment.