Skip to content

BlockId should not have a default and passing a chain tip should be an Option #1107

@LLFourn

Description

@LLFourn

It does not make sense for a BlockId to have a default. We use the Default to semantically mean a null block. e.g.

self.indexed_graph
            .graph()
            .filter_chain_unspents(
                &self.chain,
                self.chain.tip().map(|cp| cp.block_id()).unwrap_or_default(),
                self.indexed_graph.index.outpoints().iter().cloned(),
            )

I think these should just take an Option for the tip since that's the rusty way of communicating null. When it's None it should just be assumed that nothing is in the chain.
Maybe the tip should take an argument that is Option<B> where B: Into<BlockId> to avoid the map.

On a related note ChainOracle has get_chain_tip despite this not being used anywhere. I'd say we should remove it. Perhaps we will want this later but we can just make a new trait for that like GetChainTip.

Metadata

Metadata

Assignees

Labels

new featureNew feature or request

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions