Skip to content

rpc: fetch block from peer #20155

@Sjors

Description

@Sjors

The node is very efficient at not downloading blocks it doesn't care about. E.g. if a peer has headers for a lower proof-of-work branch, we won't fetch the full block. It'll appear as headers-only or valid-headers in getchaintips.

This is fine, but if a user is curious about a block, there's no easy way to obtain it.

  1. you can call invalidateblock on the current tip and wait for the node to jump to the other branch
  2. you can use some other software to obtain the block via p2p and then feed it to the node with submitblock

It would be nice if you can just fetch it from a peer, if you know they have it. In the most simple implementation, the user has to specify which node to ask. A more fancy version could automatically try all nodes, and perhaps even randomly connect to new peers until it finds the block.

Usage:

bitcoin-cli getblockfrompeer HASH peer_n

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions