Skip to content

Commit

Permalink
Update encoding.go
Browse files Browse the repository at this point in the history
optimization code
  • Loading branch information
Sarlor authored Jun 7, 2018
1 parent 90b2277 commit 02cade4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions trie/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ func hexToCompact(hex []byte) []byte {

func compactToHex(compact []byte) []byte {
base := keybytesToHex(compact)
base = base[:len(base)-1]
// apply terminator flag
if base[0] >= 2 {
base = append(base, 16)
// delete terminator flag
if base[0] < 2 {
base = base[:len(base)-1]
}
// apply odd flag
chop := 2 - base[0]&1
Expand Down

0 comments on commit 02cade4

Please sign in to comment.