Context
This is an implementation of Option 4 from #8390
Tech notes
Option 4
Keep the existing verbosity levels and allow users to, instead of providing a verbosity level, provide a query with exact fields they're interested in on a per-request basis by replacing Zebra's getblock method's verbosity argument type with an enum:
Example
pub trait Rpc {
fn get_block(&self, hash_or_height: String, query: BlockQuery) -> BoxFuture<Result<GetBlock>>;
..
}
#[derive(Debug, Eq, PartialEq, Hash, serde::Deserialize)]
enum BlockField {
Hash,
Height,
Time,
Confirmations,
AuthDataRoot,
MerkleRoot,
..
}
#[derive(serde::Deserialize)]
#[serde(untagged)]
enum BlockQuery {
#[serde(alias = "0")]
Raw,
#[serde(alias = "1")]
Json,
#[serde(alias = "2")]
Verbose,
Fields(HashSet<BlockField>),
}
And replace the zebra_state::Request::BlockHeader(HashOrHeight) variant with a Request::BlockQuery(BlockQuery) variant, and its response variant, BlockHeader(Option<Arc<block::Header>>), with:
Example
enum BlockQueryTx {
Full(zebra_chain::Transaction),
Id(transaction::Hash),
}
enum Response {
BlockQuery {
// optional version of every field on Header, could add nested options for sapling/orchard tree fields too
version: Option<u32>,
previous_block_hash: Option<Hash>,
merkle_root: Option<merkle::Root>,
..
transactions: Vec<zebra_chain::Transaction>
}
}
This has the added benefit of allowing for requesting specific block data from the state service without adding new state requests going forward, instead of expecting just a particular Response variant, it would expect the BlockQuery variant with the requested combination of fields being Some.
Context
This is an implementation of Option 4 from #8390
Tech notes
Keep the existing verbosity levels and allow users to, instead of providing a verbosity level, provide a query with exact fields they're interested in on a per-request basis by replacing Zebra's
getblockmethod'sverbosityargument type with an enum:Example
And replace the
zebra_state::Request::BlockHeader(HashOrHeight)variant with aRequest::BlockQuery(BlockQuery)variant, and its response variant,BlockHeader(Option<Arc<block::Header>>), with:Example
This has the added benefit of allowing for requesting specific block data from the state service without adding new state requests going forward, instead of expecting just a particular Response variant, it would expect the
BlockQueryvariant with the requested combination of fields beingSome.