drand: fix beacon cache
This commit is contained in:
parent
eb10918470
commit
ab811e2e19
@ -168,8 +168,8 @@ func (db *DrandBeacon) getCachedValue(round uint64) *types.BeaconEntry {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
e, _ := v.(*types.BeaconEntry)
|
e, _ := v.(types.BeaconEntry)
|
||||||
return e
|
return &e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntry) error {
|
func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntry) error {
|
||||||
@ -178,6 +178,9 @@ func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntr
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if be := db.getCachedValue(curr.Round); be != 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 no error if the value is in the cache already
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user