Add enum for nullifier type

This commit is contained in:
Eirik Ogilvie-Wigley
2018-04-23 14:37:17 -06:00
parent 685e936c31
commit 708c87f16d
11 changed files with 97 additions and 44 deletions

View File

@@ -52,9 +52,20 @@ bool CCoinsViewDB::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree)
return read;
}
bool CCoinsViewDB::GetNullifier(const uint256 &nf, bool isSapling) const {
bool CCoinsViewDB::GetNullifier(const uint256 &nf, NullifierType type) const {
bool spent = false;
return db.Read(make_pair(isSapling ? DB_SAPLING_NULLIFIER : DB_NULLIFIER, nf), spent);
char dbChar;
switch (type) {
case SPROUT_NULLIFIER:
dbChar = DB_NULLIFIER;
break;
case SAPLING_NULLIFIER:
dbChar = DB_SAPLING_NULLIFIER;
break;
default:
throw runtime_error("Unknown nullifier type " + type);
}
return db.Read(make_pair(dbChar, nf), spent);
}
bool CCoinsViewDB::GetCoins(const uint256 &txid, CCoins &coins) const {