MCPcopy Create free account
hub / github.com/CPChain/chain / GetBlockRlp

Method GetBlockRlp

internal/cpcapi/api.go:1695–1705  ·  view source on GitHub ↗

GetBlockRlp retrieves the RLP encoded for of a single block.

(ctx context.Context, number uint64)

Source from the content-addressed store, hash-verified

1693
1694// GetBlockRlp retrieves the RLP encoded for of a single block.
1695func (api *PublicDebugAPI) GetBlockRlp(ctx context.Context, number uint64) (string, error) {
1696 block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number))
1697 if block == nil {
1698 return "", fmt.Errorf("block #%d not found", number)
1699 }
1700 encoded, err := rlp.EncodeToBytes(block)
1701 if err != nil {
1702 return "", err
1703 }
1704 return fmt.Sprintf("%x", encoded), nil
1705}
1706
1707// PrintBlock retrieves a block and returns its pretty printed form.
1708func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error) {

Callers

nothing calls this directly

Calls 2

BlockNumberMethod · 0.80
BlockByNumberMethod · 0.65

Tested by

no test coverage detected