mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
take lock once in get_header_for_output (#2161)
This commit is contained in:
parent
d6131f2716
commit
9a4895c86a
1 changed files with 5 additions and 7 deletions
|
@ -1123,11 +1123,9 @@ impl Chain {
|
|||
&self,
|
||||
output_ref: &OutputIdentifier,
|
||||
) -> Result<BlockHeader, Error> {
|
||||
let pos = {
|
||||
let txhashset = self.txhashset.read();
|
||||
let (_, pos) = txhashset.is_unspent(output_ref)?;
|
||||
pos
|
||||
};
|
||||
let txhashset = self.txhashset.read();
|
||||
|
||||
let (_, pos) = txhashset.is_unspent(output_ref)?;
|
||||
|
||||
let mut min = 1;
|
||||
let mut max = {
|
||||
|
@ -1137,8 +1135,8 @@ impl Chain {
|
|||
|
||||
loop {
|
||||
let search_height = max - (max - min) / 2;
|
||||
let h = self.get_header_by_height(search_height)?;
|
||||
let h_prev = self.get_header_by_height(search_height - 1)?;
|
||||
let h = txhashset.get_header_by_height(search_height)?;
|
||||
let h_prev = txhashset.get_header_by_height(search_height - 1)?;
|
||||
if pos > h.output_mmr_size {
|
||||
min = search_height;
|
||||
} else if pos < h_prev.output_mmr_size {
|
||||
|
|
Loading…
Reference in a new issue