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) 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
state = proto.Clone(cached.(*pb.BeaconState)).(*pb.BeaconState) if cached.(*pb.BeaconState).Slot <= slot {
highestSlot = state.Slot state = proto.Clone(cached.(*pb.BeaconState)).(*pb.BeaconState)
skipSlotCacheHit.Inc() highestSlot = state.Slot
} else { skipSlotCacheHit.Inc()
skipSlotCacheMiss.Inc() } else {
skipSlotCacheMiss.Inc()
}
} }
} }

View File

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