Make query-related structs and members private

This commit is contained in:
Roman Zeyde 2018-05-20 22:58:26 +03:00
parent d9b0e0c917
commit 935c3cfb7b
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
2 changed files with 17 additions and 13 deletions

View File

@ -16,27 +16,31 @@ use util::{FullHash, HashPrefix, HeaderEntry};
error_chain!{}
pub struct FundingOutput {
pub txn_id: Sha256dHash,
pub height: i32,
pub output_index: usize,
pub value: u64,
struct FundingOutput {
txn_id: Sha256dHash,
height: i32,
output_index: usize,
value: u64,
}
pub struct SpendingInput {
pub txn_id: Sha256dHash,
pub height: i32,
pub input_index: usize,
struct SpendingInput {
txn_id: Sha256dHash,
height: i32,
input_index: usize,
}
pub struct Status {
// TODO: make private
pub balance: u64,
pub funding: Vec<FundingOutput>,
pub spending: Vec<SpendingInput>,
balance: u64,
funding: Vec<FundingOutput>,
spending: Vec<SpendingInput>,
}
impl Status {
pub fn balance(&self) -> u64 {
self.balance
}
pub fn history(&self) -> Vec<(i32, Sha256dHash)> {
let mut txns_map = HashMap::<Sha256dHash, i32>::new();
for f in &self.funding {

View File

@ -123,7 +123,7 @@ impl<'a> Connection<'a> {
fn blockchain_scripthash_get_balance(&self, params: &[Value]) -> Result<Value> {
let script_hash = hash_from_value(params.get(0)).chain_err(|| "bad script_hash")?;
let status = self.query.status(&script_hash[..]);
Ok(json!({ "confirmed": status.balance })) // TODO: "unconfirmed"
Ok(json!({ "confirmed": status.balance() })) // TODO: "unconfirmed"
}
fn blockchain_scripthash_get_history(&self, params: &[Value]) -> Result<Value> {