Skip to content

Commit

Permalink
get_unspent api changed to take a commitment directly
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp committed Sep 1, 2020
1 parent f29fc93 commit e8dc39b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 6 additions & 13 deletions impls/src/test_framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::api;
use crate::chain;
use crate::chain::Chain;
use crate::core;
use crate::core::core::{Output, OutputFeatures, OutputIdentifier, Transaction, TxKernel};
use crate::core::core::{Output, Transaction, TxKernel};
use crate::core::{consensus, global, pow};
use crate::keychain;
use crate::libwallet;
Expand All @@ -36,18 +36,11 @@ mod testclient;
pub use self::{testclient::LocalWalletClient, testclient::WalletProxy};

/// Get an output from the chain locally and present it back as an API output
fn get_output_local(chain: &chain::Chain, commit: &pedersen::Commitment) -> Option<api::Output> {
let outputs = [
OutputIdentifier::new(OutputFeatures::Plain, commit),
OutputIdentifier::new(OutputFeatures::Coinbase, commit),
];

for x in outputs.iter() {
if chain.get_unspent(&x).unwrap().is_some() {
let block_height = chain.get_header_for_output(&x).unwrap().height;
let output_pos = chain.get_output_pos(&x.commit).unwrap_or(0);
return Some(api::Output::new(&commit, block_height, output_pos));
}
fn get_output_local(chain: &chain::Chain, commit: pedersen::Commitment) -> Option<api::Output> {
if chain.get_unspent(commit).unwrap().is_some() {
let block_height = chain.get_header_for_output(commit).unwrap().height;
let output_pos = chain.get_output_pos(&commit).unwrap_or(0);
return Some(api::Output::new(&commit, block_height, output_pos));
}
None
}
Expand Down
2 changes: 1 addition & 1 deletion impls/src/test_framework/testclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ where
}
let c = util::from_hex(&o_str).unwrap();
let commit = Commitment::from_vec(c);
let out = super::get_output_local(&self.chain.clone(), &commit);
let out = super::get_output_local(&self.chain.clone(), commit);
if let Some(o) = out {
outputs.push(o);
}
Expand Down

0 comments on commit e8dc39b

Please sign in to comment.