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)
| 189 | // getBlock sends a get-block RPC request to another Core |
| 190 | // for the next block. |
| 191 | func 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. |
no test coverage detected