-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18a624c
commit 396258d
Showing
7 changed files
with
713 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package common | ||
|
||
import "encoding/binary" | ||
|
||
// BlockNum2Bytes converts a block number to a byte slice | ||
func BlockNum2Bytes(blockNum uint64) []byte { | ||
key := make([]byte, 8) | ||
binary.LittleEndian.PutUint64(key, blockNum) | ||
|
||
return key | ||
} | ||
|
||
// Bytes2BlockNum converts a byte slice to a block number | ||
func Bytes2BlockNum(key []byte) uint64 { | ||
return binary.LittleEndian.Uint64(key) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.