getBlockRPC returns the block at the requested height. If successful, it always returns at least one block, waiting if necessary until one is created. It is an error to request blocks very far in the future.
(ctx context.Context, height uint64)
| 16 | // waiting if necessary until one is created. |
| 17 | // It is an error to request blocks very far in the future. |
| 18 | func (a *API) getBlockRPC(ctx context.Context, height uint64) (chainjson.HexBytes, error) { |
| 19 | err := <-a.chain.BlockSoonWaiter(ctx, height) |
| 20 | if err != nil { |
| 21 | return nil, errors.Wrapf(err, "waiting for block at height %d", height) |
| 22 | } |
| 23 | |
| 24 | rawBlock, err := a.store.GetRawBlock(ctx, height) |
| 25 | if err != nil { |
| 26 | return nil, err |
| 27 | } |
| 28 | |
| 29 | return rawBlock, nil |
| 30 | } |
| 31 | |
| 32 | type snapshotInfoResp struct { |
| 33 | Height uint64 `json:"height"` |