mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
d62e989a67
* Remove unused fields and function * Rename splitInfo to finalizedInfo * Merge branch 'master' into stategen-cleanup * Fmt * Merge branch 'stategen-cleanup' of github.com:prysmaticlabs/prysm into stategen-cleanup * Merge refs/heads/master into stategen-cleanup
28 lines
783 B
Go
28 lines
783 B
Go
package stategen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
// SaveState saves the state in the DB.
|
|
// It knows which cold and hot state section the input state should belong to.
|
|
func (s *State) SaveState(ctx context.Context, root [32]byte, state *state.BeaconState) error {
|
|
ctx, span := trace.StartSpan(ctx, "stateGen.SaveState")
|
|
defer span.End()
|
|
|
|
// The state belongs to the cold section if it's below the split slot threshold.
|
|
if state.Slot() < s.finalizedInfo.slot {
|
|
return s.saveColdState(ctx, root, state)
|
|
}
|
|
|
|
return s.saveHotState(ctx, root, state)
|
|
}
|
|
|
|
// DeleteHotStateInCache deletes the hot state entry from the cache.
|
|
func (s *State) DeleteHotStateInCache(root [32]byte) {
|
|
s.hotStateCache.Delete(root)
|
|
}
|