Skip to content

Commit

Permalink
Merge pull request #6164 from filecoin-project/fix/drand-cache
Browse files Browse the repository at this point in the history
drand: fix beacon cache
  • Loading branch information
arajasek authored May 1, 2021
2 parents 0d253c3 + ab811e2 commit 2a90de3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chain/beacon/drand/drand.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ func (db *DrandBeacon) getCachedValue(round uint64) *types.BeaconEntry {
if !ok {
return nil
}
e, _ := v.(*types.BeaconEntry)
return e
e, _ := v.(types.BeaconEntry)
return &e
}

func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntry) error {
Expand All @@ -178,6 +178,9 @@ func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntr
return nil
}
if be := db.getCachedValue(curr.Round); be != nil {
if !bytes.Equal(curr.Data, be.Data) {
return xerrors.New("invalid beacon value, does not match cached good value")
}
// return no error if the value is in the cache already
return nil
}
Expand Down

0 comments on commit 2a90de3

Please sign in to comment.