forked from prysmaticlabs/prysm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setter.go
27 lines (21 loc) · 779 Bytes
/
setter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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.splitInfo.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)
}