MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / Bootstrap

Method Bootstrap

state/store.go:207–233  ·  view source on GitHub ↗

BootstrapState saves a new state, used e.g. by state sync when starting from non-zero height.

(state State)

Source from the content-addressed store, hash-verified

205
206// BootstrapState saves a new state, used e.g. by state sync when starting from non-zero height.
207func (store dbStore) Bootstrap(state State) error {
208 height := state.LastBlockHeight + 1
209 if height == 1 {
210 height = state.InitialHeight
211 }
212
213 if height > 1 && !state.LastValidators.IsNilOrEmpty() {
214 if err := store.saveValidatorsInfo(height-1, height-1, state.LastValidators); err != nil {
215 return err
216 }
217 }
218
219 if err := store.saveValidatorsInfo(height, height, state.Validators); err != nil {
220 return err
221 }
222
223 if err := store.saveValidatorsInfo(height+1, height+1, state.NextValidators); err != nil {
224 return err
225 }
226
227 if err := store.saveConsensusParamsInfo(height,
228 state.LastHeightConsensusParamsChanged, state.ConsensusParams); err != nil {
229 return err
230 }
231
232 return store.db.SetSync(stateKey, state.Bytes())
233}
234
235// PruneStates deletes states between the given heights (including from, excluding to). It is not
236// guaranteed to delete all states, since the last checkpointed state and states being pointed to by

Callers

nothing calls this directly

Calls 4

saveValidatorsInfoMethod · 0.95
IsNilOrEmptyMethod · 0.80
BytesMethod · 0.65

Tested by

no test coverage detected