add to cache (#1988)

This commit is contained in:
Nishant Das 2019-03-14 14:43:39 +08:00 committed by GitHub
parent e5f66d0b21
commit d5c05f083b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,6 +175,12 @@ func (db *BeaconDB) UpdateChainHead(block *pb.BeaconBlock, beaconState *pb.Beaco
return fmt.Errorf("unable to encode beacon state: %v", err)
}
currentState, ok := proto.Clone(beaconState).(*pb.BeaconState)
if !ok {
return errors.New("could not clone beacon state")
}
db.currentState = currentState
slotBinary := encodeSlotNumber(block.Slot)
return db.update(func(tx *bolt.Tx) error {