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

Method LoadBlockPart

store/store.go:149–170  ·  view source on GitHub ↗

LoadBlockPart returns the Part at the given index from the block at the given height. If no part is found for the given height and index, it returns nil.

(height int64, index int)

Source from the content-addressed store, hash-verified

147// from the block at the given height.
148// If no part is found for the given height and index, it returns nil.
149func (bs *BlockStore) LoadBlockPart(height int64, index int) *types.Part {
150 var pbpart = new(tmproto.Part)
151
152 bz, err := bs.db.Get(calcBlockPartKey(height, index))
153 if err != nil {
154 panic(err)
155 }
156 if len(bz) == 0 {
157 return nil
158 }
159
160 err = proto.Unmarshal(bz, pbpart)
161 if err != nil {
162 panic(fmt.Errorf("unmarshal to tmproto.Part failed: %w", err))
163 }
164 part, err := types.PartFromProto(pbpart)
165 if err != nil {
166 panic(fmt.Sprintf("Error reading block part: %v", err))
167 }
168
169 return part
170}
171
172// LoadBlockMeta returns the BlockMeta for the given height.
173// If no block is found for the given height, it returns nil.

Callers 2

LoadBlockMethod · 0.95
TestPruneBlocksFunction · 0.95

Implementers 4

BlockStorestate/mocks/block_store.go
BlockStorestore/store.go
mockBlockStorerpc/core/blocks_test.go
mockBlockStoreconsensus/replay_test.go

Calls 4

PartFromProtoFunction · 0.92
calcBlockPartKeyFunction · 0.85
GetMethod · 0.65
UnmarshalMethod · 0.45

Tested by 1

TestPruneBlocksFunction · 0.76