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,9 +259,10 @@ func ProcessSlots(ctx context.Context, state *pb.BeaconState, slot uint64) (*pb.
cached, ok := skipSlotCache.Get(root) cached, ok := skipSlotCache.Get(root)
// if cache key does not exist, we write it to the cache. // if cache key does not exist, we write it to the cache.
writeToCache = !ok writeToCache = !ok
if ok && cached.(*pb.BeaconState).Slot <= slot { if ok {
// do not write to cache if state with higher slot exists. // do not write to cache if state with higher slot exists.
writeToCache = writeToCache || cached.(*pb.BeaconState).Slot <= slot writeToCache = cached.(*pb.BeaconState).Slot <= slot
if cached.(*pb.BeaconState).Slot <= slot {
state = proto.Clone(cached.(*pb.BeaconState)).(*pb.BeaconState) state = proto.Clone(cached.(*pb.BeaconState)).(*pb.BeaconState)
highestSlot = state.Slot highestSlot = state.Slot
skipSlotCacheHit.Inc() skipSlotCacheHit.Inc()
@ -269,6 +270,7 @@ func ProcessSlots(ctx context.Context, state *pb.BeaconState, slot uint64) (*pb.
skipSlotCacheMiss.Inc() skipSlotCacheMiss.Inc()
} }
} }
}
for state.Slot < slot { for state.Slot < slot {
if ctx.Err() != nil { if ctx.Err() != nil {

View File

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