Skip to content

Commit

Permalink
nodeHeaderShift constant
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jan 5, 2022
1 parent f986135 commit aed41cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/trie/node/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ const (
// encodeHeader creates the encoded header for the branch.
func (b *Branch) encodeHeader(writer io.Writer) (err error) {
var header byte
const nodeHeaderShift = 6
if b.Value == nil {
header = byte(BranchType) << 6
header = byte(BranchType) << nodeHeaderShift
} else {
header = byte(BranchWithValueType) << 6
header = byte(BranchWithValueType) << nodeHeaderShift
}

if len(b.Key) >= keyLenOffset {
Expand All @@ -44,7 +45,8 @@ func (b *Branch) encodeHeader(writer io.Writer) (err error) {

// encodeHeader creates the encoded header for the leaf.
func (l *Leaf) encodeHeader(writer io.Writer) (err error) {
header := byte(LeafType) << 6
const nodeHeaderShift = 6
header := byte(LeafType) << nodeHeaderShift

if len(l.Key) < 63 {
header |= byte(len(l.Key))
Expand Down

0 comments on commit aed41cd

Please sign in to comment.