From c0cc5c0295915020e09d6e5dec20d4b004e61def Mon Sep 17 00:00:00 2001 From: Jerry Fireman Date: Thu, 11 Apr 2019 15:50:16 -0400 Subject: [PATCH] Update docs (#2173) * Update docs * Update docs --- beacon-chain/db/state.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/beacon-chain/db/state.go b/beacon-chain/db/state.go index e00c4104a..1ac099c43 100644 --- a/beacon-chain/db/state.go +++ b/beacon-chain/db/state.go @@ -261,7 +261,8 @@ func (db *BeaconDB) FinalizedState() (*pb.BeaconState, error) { 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) { _, span := trace.StartSpan(ctx, "BeaconDB.HistoricalStateFromSlot") defer span.End() @@ -286,7 +287,8 @@ func (db *BeaconDB) HistoricalStateFromSlot(ctx context.Context, slot uint64) (* break } } - // If no state exists send the closest state. + + // If no historical state exists, retrieve and decode the finalized state. if !stateExists { for k, v := hsCursor.First(); k != nil; k, v = hsCursor.Next() { 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) if encState == nil { return errors.New("no historical state saved")