diff options
author | James O'Beirne <james.obeirne@pm.me> | 2021-06-16 16:27:20 -0400 |
---|---|---|
committer | James O'Beirne <james.obeirne@pm.me> | 2021-06-17 09:47:08 -0400 |
commit | 615c1adfb07b9b466173166dc2e53ace540e4b32 (patch) | |
tree | 4261a142c5886d8ec309292c0b91bd78e6861b8c /src/coins.h | |
parent | 6bc1eca01b2f88e081e71b783b3d45287700f8a5 (diff) |
refactor: wrap CCoinsViewCursor in unique_ptr
Specifically with CCoinsViewDB, if a raw cursor is allocated and
not freed, a cryptic leveldb assertion failure occurs on
CCoinsViewDB destruction.
See: https://github.com/google/leveldb/issues/142#issuecomment-414418135
Diffstat (limited to 'src/coins.h')
-rw-r--r-- | src/coins.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/coins.h b/src/coins.h index 816b4864a3..3151a260d9 100644 --- a/src/coins.h +++ b/src/coins.h @@ -180,7 +180,7 @@ public: virtual bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock); //! Get a cursor to iterate over the whole state - virtual CCoinsViewCursor *Cursor() const; + virtual std::unique_ptr<CCoinsViewCursor> Cursor() const; //! As we use CCoinsViews polymorphically, have a virtual destructor virtual ~CCoinsView() {} @@ -204,7 +204,7 @@ public: std::vector<uint256> GetHeadBlocks() const override; void SetBackend(CCoinsView &viewIn); bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) override; - CCoinsViewCursor *Cursor() const override; + std::unique_ptr<CCoinsViewCursor> Cursor() const override; size_t EstimateSize() const override; }; @@ -237,7 +237,7 @@ public: uint256 GetBestBlock() const override; void SetBestBlock(const uint256 &hashBlock); bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) override; - CCoinsViewCursor* Cursor() const override { + std::unique_ptr<CCoinsViewCursor> Cursor() const override { throw std::logic_error("CCoinsViewCache cursor iteration not supported."); } |