Skip to content

Commit

Permalink
Debug stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sakridge committed May 10, 2018
1 parent 84aaca6 commit d1403c9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/accountant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct Accountant {
last_ids: RwLock<VecDeque<(Hash, RwLock<HashSet<Signature>>)>>,
time_sources: RwLock<HashSet<PublicKey>>,
last_time: RwLock<DateTime<Utc>>,
counter: RwLock<u64>,
}

impl Accountant {
Expand All @@ -60,6 +61,7 @@ impl Accountant {
last_ids: RwLock::new(VecDeque::new()),
time_sources: RwLock::new(HashSet::new()),
last_time: RwLock::new(Utc.timestamp(0, 0)),
counter: RwLock::new(0),
}
}

Expand All @@ -83,6 +85,7 @@ impl Accountant {

fn reserve_signature(signatures: &RwLock<HashSet<Signature>>, sig: &Signature) -> bool {
if signatures.read().unwrap().contains(sig) {
trace!("signatures already contains signature");
return false;
}
signatures.write().unwrap().insert(*sig);
Expand Down Expand Up @@ -116,6 +119,9 @@ impl Accountant {
{
return Self::reserve_signature(&entry.1, sig);
}
trace!("reserve_signature didn't find id");
trace!("id: {:?}", last_id);
trace!("{:?}", self.last_ids);
false
}

Expand Down Expand Up @@ -173,6 +179,7 @@ impl Accountant {
plan.apply_witness(&Witness::Timestamp(*self.last_time.read().unwrap()));

if let Some(ref payment) = plan.final_payment() {
*self.counter.write().unwrap() += 1;
apply_payment(&self.balances, payment);
} else {
let mut pending = self.pending.write().unwrap();
Expand Down Expand Up @@ -220,6 +227,7 @@ impl Accountant {

pub fn process_verified_events(&self, events: Vec<Event>) -> Vec<Result<Event>> {
let (trs, rest) = Self::partition_events(events);
trace!("trs: {} rest: {}", trs.len(), rest.len());
let mut results: Vec<_> = self.process_verified_transactions(trs)
.into_iter()
.map(|x| x.map(Event::Transaction))
Expand All @@ -228,6 +236,7 @@ impl Accountant {
for event in rest {
results.push(self.process_verified_event(event));
}
trace!("results: {} counter: {}", results.len(), self.counter.read().unwrap());

results
}
Expand Down

0 comments on commit d1403c9

Please sign in to comment.