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)
| 147 | // from the block at the given height. |
| 148 | // If no part is found for the given height and index, it returns nil. |
| 149 | func (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. |