diff --git a/chain/src/sumtree.rs b/chain/src/sumtree.rs index 12fb8e547..bfbc64001 100644 --- a/chain/src/sumtree.rs +++ b/chain/src/sumtree.rs @@ -241,11 +241,15 @@ impl<'a> Extension<'a> { // doing inputs first guarantees an input can't spend an output in the // same block, enforcing block cut-through for input in &b.inputs { - let pos_res = self.commit_index.get_output_pos(&input.commitment()); + let commit = input.commitment(); + let pos_res = self.commit_index.get_output_pos(&commit); + + // TODO - Assume this hash specific debug can be cleaned up? if b.hash().to_string() == "f697a877" { debug!(LOGGER, "input pos: {:?}, commit: {} {:?}", - pos_res, input.commitment().hash(), input.commitment()); + pos_res, input.commitment().hash(), commit); } + if let Ok(pos) = pos_res { match self.output_pmmr.prune(pos, b.header.height as u32) { Ok(true) => { @@ -253,11 +257,11 @@ impl<'a> Extension<'a> { .prune(pos, b.header.height as u32) .map_err(|s| Error::SumTreeErr(s))?; } - Ok(false) => return Err(Error::AlreadySpent), + Ok(false) => return Err(Error::AlreadySpent(commit)), Err(s) => return Err(Error::SumTreeErr(s)), } } else { - return Err(Error::AlreadySpent); + return Err(Error::AlreadySpent(commit)); } } @@ -276,7 +280,7 @@ impl<'a> Extension<'a> { // fork that exists but matches a different node, filtering that // case out if c.hash == hashsum.hash { - return Err(Error::DuplicateCommitment(out.commitment())); + return Err(Error::DuplicateCommitment(commit)); } } } diff --git a/chain/src/types.rs b/chain/src/types.rs index 86872c5be..15c08a068 100644 --- a/chain/src/types.rs +++ b/chain/src/types.rs @@ -59,7 +59,7 @@ pub enum Error { /// One of the root hashes in the block is invalid InvalidRoot, /// One of the inputs in the block has already been spent - AlreadySpent, + AlreadySpent(Commitment), /// An output with that commitment already exists (should be unique) DuplicateCommitment(Commitment), /// A kernel with that excess commitment already exists (should be unique)