Skip to content

Commit

Permalink
Change tui tx_pool lock to try_read, only lock once (#3063)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume authored Sep 28, 2019
1 parent 142dfb1 commit f86eb18
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions servers/src/grin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,17 @@ impl Server {
.map(|p| PeerStats::from_peer(&p))
.collect();

let (tx_pool_size, stem_pool_size) = {
let tx_pool_lock = self.tx_pool.try_read();
match tx_pool_lock {
Some(l) => (l.txpool.entries.len(), l.stempool.entries.len()),
None => (0, 0),
}
};

let tx_stats = TxStats {
tx_pool_size: self.tx_pool.read().txpool.entries.len(),
stem_pool_size: self.tx_pool.read().stempool.entries.len(),
tx_pool_size,
stem_pool_size,
};

let head = self.chain.head_header()?;
Expand Down

0 comments on commit f86eb18

Please sign in to comment.