mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
pass the commitment into an AlreadySpent error (#511)
This commit is contained in:
parent
2caa0b79e0
commit
3b5e6d3e1f
2 changed files with 10 additions and 6 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue