Better comments for PMMR size check

This commit is contained in:
Ignotus Peverell 2017-11-22 15:50:59 -05:00
parent 5807a6b270
commit 31f8f2ad3e
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211

View file

@ -94,6 +94,8 @@ impl SumTrees {
let rpos = self.commit_index.get_output_pos(commit);
match rpos {
Ok(pos) => {
// checking the position is within the MMR, the commit index could be
// returning rewound data
if pos > self.output_pmmr_h.last_pos {
Ok(false)
} else {
@ -259,6 +261,8 @@ impl<'a> Extension<'a> {
for out in &b.outputs {
if let Ok(pos) = self.commit_index.get_output_pos(&out.commitment()) {
// checking the position is within the MMR, the commit index could be
// returning rewound data
if pos <= self.output_pmmr.unpruned_size() {
return Err(Error::DuplicateCommitment(out.commitment()));
}
@ -284,6 +288,8 @@ impl<'a> Extension<'a> {
for kernel in &b.kernels {
if let Ok(pos) = self.commit_index.get_kernel_pos(&kernel.excess) {
if pos <= self.kernel_pmmr.unpruned_size() {
// checking the position is within the MMR, the commit index could be
// returning rewound data
return Err(Error::DuplicateKernel(kernel.excess.clone()));
}
}