mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
parent
b6bd8ba63d
commit
c0cc5c0295
@ -261,7 +261,8 @@ func (db *BeaconDB) FinalizedState() (*pb.BeaconState, error) {
|
|||||||
return beaconState, err
|
return beaconState, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// HistoricalStateFromSlot retrieves the closest historical state to a slot.
|
// HistoricalStateFromSlot retrieves the state that is closest to the input slot,
|
||||||
|
// while being smaller than or equal to the input slot.
|
||||||
func (db *BeaconDB) HistoricalStateFromSlot(ctx context.Context, slot uint64) (*pb.BeaconState, error) {
|
func (db *BeaconDB) HistoricalStateFromSlot(ctx context.Context, slot uint64) (*pb.BeaconState, error) {
|
||||||
_, span := trace.StartSpan(ctx, "BeaconDB.HistoricalStateFromSlot")
|
_, span := trace.StartSpan(ctx, "BeaconDB.HistoricalStateFromSlot")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
@ -286,7 +287,8 @@ func (db *BeaconDB) HistoricalStateFromSlot(ctx context.Context, slot uint64) (*
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If no state exists send the closest state.
|
|
||||||
|
// If no historical state exists, retrieve and decode the finalized state.
|
||||||
if !stateExists {
|
if !stateExists {
|
||||||
for k, v := hsCursor.First(); k != nil; k, v = hsCursor.Next() {
|
for k, v := hsCursor.First(); k != nil; k, v = hsCursor.Next() {
|
||||||
slotNumber := decodeToSlotNumber(k)
|
slotNumber := decodeToSlotNumber(k)
|
||||||
@ -303,7 +305,7 @@ func (db *BeaconDB) HistoricalStateFromSlot(ctx context.Context, slot uint64) (*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve the stored historical state.
|
// If historical state exists, retrieve and decode it.
|
||||||
encState := chainInfo.Get(histStateKey)
|
encState := chainInfo.Get(histStateKey)
|
||||||
if encState == nil {
|
if encState == nil {
|
||||||
return errors.New("no historical state saved")
|
return errors.New("no historical state saved")
|
||||||
|
Loading…
Reference in New Issue
Block a user