set bool correctly (#3913)

This commit is contained in:
Nishant Das 2019-11-01 22:48:24 +08:00 committed by Raul Jordan
parent da6c270d46
commit ab92326dfb
2 changed files with 10 additions and 8 deletions

View File

@ -259,14 +259,16 @@ func ProcessSlots(ctx context.Context, state *pb.BeaconState, slot uint64) (*pb.
cached, ok := skipSlotCache.Get(root)
// if cache key does not exist, we write it to the cache.
writeToCache = !ok
if ok && cached.(*pb.BeaconState).Slot <= slot {
if ok {
// do not write to cache if state with higher slot exists.
writeToCache = writeToCache || cached.(*pb.BeaconState).Slot <= slot
state = proto.Clone(cached.(*pb.BeaconState)).(*pb.BeaconState)
highestSlot = state.Slot
skipSlotCacheHit.Inc()
} else {
skipSlotCacheMiss.Inc()
writeToCache = cached.(*pb.BeaconState).Slot <= slot
if cached.(*pb.BeaconState).Slot <= slot {
state = proto.Clone(cached.(*pb.BeaconState)).(*pb.BeaconState)
highestSlot = state.Slot
skipSlotCacheHit.Inc()
} else {
skipSlotCacheMiss.Inc()
}
}
}

View File

@ -3,8 +3,8 @@ package version
import (
"fmt"
"log"
"strings"
"os/exec"
"strings"
"time"
)