Skip to content

Commit

Permalink
rename add_terminals to add_consignment_txes
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedberg committed Feb 16, 2025
1 parent 07b6bda commit 5160fd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ impl Exec for RgbArgs {
Command::Validate { file } => {
let mut resolver = self.resolver()?;
let consignment = Transfer::load_file(file)?;
resolver.add_terminals(&consignment);
resolver.add_consignment_txes(&consignment);
let status = match consignment.validate(&resolver, self.chain_net()) {
Ok(consignment) => consignment.into_validation_status(),
Err((status, _)) => status,
Expand All @@ -1262,7 +1262,7 @@ impl Exec for RgbArgs {
let mut stock = self.rgb_stock()?;
let mut resolver = self.resolver()?;
let transfer = Transfer::load_file(file)?;
resolver.add_terminals(&transfer);
resolver.add_consignment_txes(&transfer);
let valid = transfer
.validate(&resolver, self.chain_net())
.map_err(|(status, _)| status)?;
Expand Down
20 changes: 12 additions & 8 deletions src/indexers/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub trait RgbResolver: Send {
#[non_exhaustive]
pub struct AnyResolver {
inner: Box<dyn RgbResolver>,
terminal_txes: HashMap<Txid, Tx>,
consignment_txes: HashMap<Txid, Tx>,
}

impl AnyResolver {
Expand All @@ -54,7 +54,7 @@ impl AnyResolver {
electrum::Client::from_config(url, config.unwrap_or_default())
.map_err(|e| e.to_string())?,
),
terminal_txes: Default::default(),
consignment_txes: Default::default(),
})
}

Expand All @@ -65,7 +65,7 @@ impl AnyResolver {
esplora::BlockingClient::from_config(url, config.unwrap_or_default())
.map_err(|e| e.to_string())?,
),
terminal_txes: Default::default(),
consignment_txes: Default::default(),
})
}

Expand All @@ -76,16 +76,20 @@ impl AnyResolver {
url,
config.unwrap_or_default(),
)?),
terminal_txes: Default::default(),
consignment_txes: Default::default(),
})
}

pub fn check_chain_net(&self, chain_net: ChainNet) -> Result<(), String> {
self.inner.check_chain_net(chain_net)
}

pub fn add_terminals<const TYPE: bool>(&mut self, consignment: &Consignment<TYPE>) {
self.terminal_txes.extend(
/// Add to the resolver the TXs found in the consignment bundles. Those TXs
/// will not be resolved by an indexer and will be considered tentative.
/// Use with caution, this could allow accepting a consignment containing TXs that have not
/// been broadcasted.
pub fn add_consignment_txes<const TYPE: bool>(&mut self, consignment: &Consignment<TYPE>) {
self.consignment_txes.extend(
consignment
.bundles
.iter()
Expand All @@ -97,7 +101,7 @@ impl AnyResolver {

impl ResolveWitness for AnyResolver {
fn resolve_pub_witness(&self, witness_id: Txid) -> Result<Tx, WitnessResolverError> {
if let Some(tx) = self.terminal_txes.get(&witness_id) {
if let Some(tx) = self.consignment_txes.get(&witness_id) {
return Ok(tx.clone());
}

Expand All @@ -111,7 +115,7 @@ impl ResolveWitness for AnyResolver {
&self,
witness_id: Txid,
) -> Result<WitnessOrd, WitnessResolverError> {
if self.terminal_txes.contains_key(&witness_id) {
if self.consignment_txes.contains_key(&witness_id) {
return Ok(WitnessOrd::Tentative);
}

Expand Down

0 comments on commit 5160fd5

Please sign in to comment.