Skip to content

Commit

Permalink
fix round snapshot version check
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricfung committed Oct 3, 2022
1 parent 2358988 commit 36f8476
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions kernel/round.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,22 @@ func ComputeRoundHash(nodeId crypto.Hash, number uint64, snapshots []*common.Sna
panic(err)
}

var hash crypto.Hash
version := snapshots[0].Version
for _, s := range snapshots {
if s.Version > version {
version = s.Version
}
}

var hash crypto.Hash
buf := binary.BigEndian.AppendUint64(nodeId[:], number)
if version < common.SnapshotVersionCommonEncoding {
hash = crypto.NewHash(buf)
} else {
hash = crypto.Blake3Hash(buf)
}
for _, s := range snapshots {
if s.Version != version {
if s.Version > version {
panic(nodeId)
}
if s.Timestamp > end {
Expand Down
10 changes: 8 additions & 2 deletions storage/badger_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,22 @@ func computeRoundHash(nodeId crypto.Hash, number uint64, snapshots []*common.Sna
panic(err)
}

var hash crypto.Hash
version := snapshots[0].Version
for _, s := range snapshots {
if s.Version > version {
version = s.Version
}
}

var hash crypto.Hash
buf := binary.BigEndian.AppendUint64(nodeId[:], number)
if version < common.SnapshotVersionCommonEncoding {
hash = crypto.NewHash(buf)
} else {
hash = crypto.Blake3Hash(buf)
}
for _, s := range snapshots {
if s.Version != version {
if s.Version > version {
panic(nodeId)
}
if s.Timestamp > end {
Expand Down

0 comments on commit 36f8476

Please sign in to comment.