Skip to content

Commit

Permalink
refactor to cleanup duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp committed Feb 10, 2020
1 parent dc87c77 commit de29c50
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions chain/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,7 @@ impl ChainStore {

/// Get PMMR pos for the given output commitment.
pub fn get_output_pos(&self, commit: &Commitment) -> Result<u64, Error> {
let res: Result<Option<(u64, u64)>, Error> = self
.db
.get_ser(&to_key(OUTPUT_POS_PREFIX, &mut commit.as_ref().to_vec()));
match res {
Ok(None) => Err(Error::NotFoundErr(format!(
"Output position for: {:?}",
commit
))),
Ok(Some((pos, _height))) => Ok(pos),
Err(e) => Err(e),
}
self.get_output_pos_height(commit).map(|(pos, _)| pos)
}

/// Get PMMR pos and block height for the given output commitment.
Expand Down Expand Up @@ -265,17 +255,7 @@ impl<'a> Batch<'a> {

/// Get output_pos from index.
pub fn get_output_pos(&self, commit: &Commitment) -> Result<u64, Error> {
let res: Result<Option<(u64, u64)>, Error> = self
.db
.get_ser(&to_key(OUTPUT_POS_PREFIX, &mut commit.as_ref().to_vec()));
match res {
Ok(None) => Err(Error::NotFoundErr(format!(
"Output position for: {:?}",
commit
))),
Ok(Some((pos, _height))) => Ok(pos),
Err(e) => Err(e),
}
self.get_output_pos_height(commit).map(|(pos, _)| pos)
}

/// Get output_pos and block height from index.
Expand Down

0 comments on commit de29c50

Please sign in to comment.