MCPcopy Create free account
hub / github.com/chain/Core / getBlock

Function getBlock

core/fetch/fetch.go:191–201  ·  view source on GitHub ↗

getBlock sends a get-block RPC request to another Core for the next block.

(ctx context.Context, peer *rpc.Client, height uint64, timeout time.Duration)

Source from the content-addressed store, hash-verified

189// getBlock sends a get-block RPC request to another Core
190// for the next block.
191func getBlock(ctx context.Context, peer *rpc.Client, height uint64, timeout time.Duration) (*legacy.Block, error) {
192 ctx, cancel := context.WithTimeout(ctx, timeout)
193 defer cancel()
194
195 var block *legacy.Block
196 err := peer.Call(ctx, "/rpc/get-block", height, &block)
197 if ctx.Err() == context.DeadlineExceeded {
198 return nil, nil
199 }
200 return block, errors.Wrap(err, "get blocks rpc")
201}
202
203// getHeight sends a get-height RPC request to another Core for
204// the latest height that that peer knows about.

Callers 2

DownloadBlocksFunction · 0.85
fetchSnapshotFunction · 0.85

Calls 2

CallMethod · 0.80
ErrMethod · 0.45

Tested by

no test coverage detected