Browse Source

Rename GetSerial to GetNullifier.

pull/145/head
Sean Bowe 8 years ago
parent
commit
616f8d05af
  1. 10
      src/coins.cpp
  2. 6
      src/coins.h
  3. 12
      src/test/coins_tests.cpp
  4. 2
      src/txdb.cpp
  5. 2
      src/txdb.h
  6. 6
      src/txmempool.cpp
  7. 2
      src/txmempool.h

10
src/coins.cpp

@ -41,7 +41,7 @@ bool CCoins::Spend(uint32_t nPos)
return true;
}
bool CCoinsView::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return false; }
bool CCoinsView::GetSerial(const uint256 &serial) const { return false; }
bool CCoinsView::GetNullifier(const uint256 &serial) const { return false; }
bool CCoinsView::GetCoins(const uint256 &txid, CCoins &coins) const { return false; }
bool CCoinsView::HaveCoins(const uint256 &txid) const { return false; }
uint256 CCoinsView::GetBestBlock() const { return uint256(); }
@ -57,7 +57,7 @@ bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; }
CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) { }
bool CCoinsViewBacked::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return base->GetAnchorAt(rt, tree); }
bool CCoinsViewBacked::GetSerial(const uint256 &serial) const { return base->GetSerial(serial); }
bool CCoinsViewBacked::GetNullifier(const uint256 &serial) const { return base->GetNullifier(serial); }
bool CCoinsViewBacked::GetCoins(const uint256 &txid, CCoins &coins) const { return base->GetCoins(txid, coins); }
bool CCoinsViewBacked::HaveCoins(const uint256 &txid) const { return base->HaveCoins(txid); }
uint256 CCoinsViewBacked::GetBestBlock() const { return base->GetBestBlock(); }
@ -128,13 +128,13 @@ bool CCoinsViewCache::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tr
return true;
}
bool CCoinsViewCache::GetSerial(const uint256 &serial) const {
bool CCoinsViewCache::GetNullifier(const uint256 &serial) const {
CSerialsMap::iterator it = cacheSerials.find(serial);
if (it != cacheSerials.end())
return it->second.entered;
CSerialsCacheEntry entry;
bool tmp = base->GetSerial(serial);
bool tmp = base->GetNullifier(serial);
entry.entered = tmp;
cacheSerials.insert(std::make_pair(serial, entry));
@ -398,7 +398,7 @@ bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const
{
BOOST_FOREACH(const uint256& serial, pour.nullifiers)
{
if (GetSerial(serial)) {
if (GetNullifier(serial)) {
// If the serial is set, this transaction
// double-spends!
return false;

6
src/coins.h

@ -347,7 +347,7 @@ public:
virtual bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const;
//! Determine whether a serial is spent or not
virtual bool GetSerial(const uint256 &serial) const;
virtual bool GetNullifier(const uint256 &serial) const;
//! Retrieve the CCoins (unspent transaction outputs) for a given txid
virtual bool GetCoins(const uint256 &txid, CCoins &coins) const;
@ -387,7 +387,7 @@ protected:
public:
CCoinsViewBacked(CCoinsView *viewIn);
bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const;
bool GetSerial(const uint256 &serial) const;
bool GetNullifier(const uint256 &serial) const;
bool GetCoins(const uint256 &txid, CCoins &coins) const;
bool HaveCoins(const uint256 &txid) const;
uint256 GetBestBlock() const;
@ -451,7 +451,7 @@ public:
// Standard CCoinsView methods
bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const;
bool GetSerial(const uint256 &serial) const;
bool GetNullifier(const uint256 &serial) const;
bool GetCoins(const uint256 &txid, CCoins &coins) const;
bool HaveCoins(const uint256 &txid) const;
uint256 GetBestBlock() const;

12
src/test/coins_tests.cpp

@ -47,7 +47,7 @@ public:
}
}
bool GetSerial(const uint256 &serial) const
bool GetNullifier(const uint256 &serial) const
{
std::map<uint256, bool>::const_iterator it = mapSerials_.find(serial);
@ -170,21 +170,21 @@ BOOST_AUTO_TEST_CASE(serials_test)
uint256 myserial = GetRandHash();
BOOST_CHECK(!cache.GetSerial(myserial));
BOOST_CHECK(!cache.GetNullifier(myserial));
cache.SetSerial(myserial, true);
BOOST_CHECK(cache.GetSerial(myserial));
BOOST_CHECK(cache.GetNullifier(myserial));
cache.Flush();
CCoinsViewCacheTest cache2(&base);
BOOST_CHECK(cache2.GetSerial(myserial));
BOOST_CHECK(cache2.GetNullifier(myserial));
cache2.SetSerial(myserial, false);
BOOST_CHECK(!cache2.GetSerial(myserial));
BOOST_CHECK(!cache2.GetNullifier(myserial));
cache2.Flush();
CCoinsViewCacheTest cache3(&base);
BOOST_CHECK(!cache3.GetSerial(myserial));
BOOST_CHECK(!cache3.GetNullifier(myserial));
}
BOOST_AUTO_TEST_CASE(anchors_flush_test)

2
src/txdb.cpp

@ -81,7 +81,7 @@ bool CCoinsViewDB::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree)
return read;
}
bool CCoinsViewDB::GetSerial(const uint256 &serial) const {
bool CCoinsViewDB::GetNullifier(const uint256 &serial) const {
bool spent = false;
bool read = db.Read(make_pair(DB_SERIAL, serial), spent);

2
src/txdb.h

@ -35,7 +35,7 @@ public:
CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const;
bool GetSerial(const uint256 &serial) const;
bool GetNullifier(const uint256 &serial) const;
bool GetCoins(const uint256 &txid, CCoins &coins) const;
bool HaveCoins(const uint256 &txid) const;
uint256 GetBestBlock() const;

6
src/txmempool.cpp

@ -319,7 +319,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
assert(!pcoins->GetSerial(serial));
assert(!pcoins->GetNullifier(serial));
}
ZCIncrementalMerkleTree tree;
@ -484,11 +484,11 @@ bool CTxMemPool::HasNoInputsOf(const CTransaction &tx) const
CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
bool CCoinsViewMemPool::GetSerial(const uint256 &serial) const {
bool CCoinsViewMemPool::GetNullifier(const uint256 &serial) const {
if (mempool.mapSerials.count(serial))
return true;
return base->GetSerial(serial);
return base->GetNullifier(serial);
}
bool CCoinsViewMemPool::GetCoins(const uint256 &txid, CCoins &coins) const {

2
src/txmempool.h

@ -177,7 +177,7 @@ protected:
public:
CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn);
bool GetSerial(const uint256 &txid) const;
bool GetNullifier(const uint256 &txid) const;
bool GetCoins(const uint256 &txid, CCoins &coins) const;
bool HaveCoins(const uint256 &txid) const;
};

Loading…
Cancel
Save