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

Function initializeBlockStore

evidence/pool_test.go:403–420  ·  view source on GitHub ↗

initializeBlockStore creates a block storage and populates it w/ a dummy block at +height+.

(db dbm.DB, state sm.State, valAddr []byte)

Source from the content-addressed store, hash-verified

401// initializeBlockStore creates a block storage and populates it w/ a dummy
402// block at +height+.
403func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) *store.BlockStore {
404 blockStore := store.NewBlockStore(db)
405
406 for i := int64(1); i <= state.LastBlockHeight; i++ {
407 lastCommit := makeCommit(i-1, valAddr)
408 block, _ := state.MakeBlock(i, []types.Tx{}, lastCommit, nil,
409 state.Validators.GetProposer().Address)
410 block.Header.Time = defaultEvidenceTime.Add(time.Duration(i) * time.Minute)
411 block.Header.Version = tmversion.Consensus{Block: version.BlockProtocol, App: 1}
412 const parts = 1
413 partSet := block.MakePartSet(parts)
414
415 seenCommit := makeCommit(i, valAddr)
416 blockStore.SaveBlock(block, partSet, seenCommit)
417 }
418
419 return blockStore
420}
421
422func makeCommit(height int64, valAddr []byte) *types.Commit {
423 commitSigs := []types.CommitSig{{

Callers 2

defaultTestPoolFunction · 0.85

Calls 7

SaveBlockMethod · 0.95
NewBlockStoreFunction · 0.92
makeCommitFunction · 0.85
MakeBlockMethod · 0.80
MakePartSetMethod · 0.80
GetProposerMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected