Allow pours to be anchored to intermediate treestates of a transaction.
This commit is contained in:
parent
8048f4c048
commit
6c59778acb
|
@ -386,6 +386,8 @@ CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const
|
||||||
|
|
||||||
bool CCoinsViewCache::HavePourRequirements(const CTransaction& tx) const
|
bool CCoinsViewCache::HavePourRequirements(const CTransaction& tx) const
|
||||||
{
|
{
|
||||||
|
boost::unordered_map<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
|
||||||
|
|
||||||
BOOST_FOREACH(const CPourTx &pour, tx.vpour)
|
BOOST_FOREACH(const CPourTx &pour, tx.vpour)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const uint256& serial, pour.serials)
|
BOOST_FOREACH(const uint256& serial, pour.serials)
|
||||||
|
@ -398,11 +400,19 @@ bool CCoinsViewCache::HavePourRequirements(const CTransaction& tx) const
|
||||||
}
|
}
|
||||||
|
|
||||||
ZCIncrementalMerkleTree tree;
|
ZCIncrementalMerkleTree tree;
|
||||||
if (!GetAnchorAt(pour.anchor, tree)) {
|
auto it = intermediates.find(pour.anchor);
|
||||||
// If we do not have the anchor for the pour,
|
if (it != intermediates.end()) {
|
||||||
// it is invalid.
|
tree = it->second;
|
||||||
|
} else if (!GetAnchorAt(pour.anchor, tree)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_FOREACH(const uint256& commitment, pour.commitments)
|
||||||
|
{
|
||||||
|
tree.append(commitment);
|
||||||
|
}
|
||||||
|
|
||||||
|
intermediates.insert(std::make_pair(tree.root(), tree));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue