Make query-related structs and members private
This commit is contained in:
parent
d9b0e0c917
commit
935c3cfb7b
28
src/query.rs
28
src/query.rs
|
@ -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 {
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Reference in New Issue
Block a user