Add cursor to iterate over utxo set, use this in gettxoutsetinfo #7756

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2016_03_utxo_cursor changing 6 files +148 −57
  1. laanwj commented at 4:48 pm on March 28, 2016: member

    I need this for something else, but I think this is simply a better API. I also vaguely remember this has been discussed before.

    • Add a method Cursor() to CCoinsView that returns a cursor which can be used to iterate over the whole UTXO set.
    • Implement GetUTXOStats in terms of this, remove GetStats() method on CCoinsView.
    • Change gettxoutsetinfo RPC to use new GetUTXOStats function.

    This is not yet enough to break the dependency of txdb.cpp/h on main (there’s CDiskTxPos to cope with, for example), but it is a step toward that (see #7815).

  2. laanwj added the label UTXO Db and Indexes on Mar 28, 2016
  3. laanwj added the label RPC on Mar 28, 2016
  4. laanwj force-pushed on Mar 30, 2016
  5. laanwj commented at 9:12 am on March 31, 2016: member
  6. laanwj force-pushed on Apr 6, 2016
  7. laanwj commented at 11:05 am on April 6, 2016: member
    Rebased
  8. in src/coins.cpp: in c1331def20 outdated
    44@@ -45,7 +45,7 @@ bool CCoinsView::GetCoins(const uint256 &txid, CCoins &coins) const { return fal
    45 bool CCoinsView::HaveCoins(const uint256 &txid) const { return false; }
    46 uint256 CCoinsView::GetBestBlock() const { return uint256(); }
    47 bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { return false; }
    48-bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; }
    49+CCoinsViewCursor *CCoinsView::Cursor() const { return 0; }
    


    sipa commented at 11:10 am on April 6, 2016:
    Using NULL would be clearer as it’s a pointer.

    laanwj commented at 12:05 pm on April 6, 2016:
    Bjarne Stroustrup taught me not to use NULL in c++ code: http://www.stroustrup.com/bs_faq2.html#null I don’t care deeply about this though.

    sipa commented at 2:49 pm on April 6, 2016:
    Interesting. Comment retracted.
  9. sipa commented at 11:28 am on April 6, 2016: member
    • rpc: Add method gettxoutsetinfo2 that uses new Cursor method

    That seems outdated.

  10. laanwj commented at 12:02 pm on April 6, 2016: member

    That seems outdated.

    Yes, I’ve removed that in the rebase, I had multiple commits with two getutxosetinfo in an intermediate step but that was annoying to rebase over #7766.

  11. laanwj force-pushed on Apr 6, 2016
  12. in src/txdb.cpp: in eacf28cb38 outdated
    166+    return pcursor->Valid();
    167+}
    168+
    169+void CCoinsViewDBCursor::Next()
    170+{
    171+    while (true) {
    


    sipa commented at 2:52 pm on April 6, 2016:
    This should never loop more than once, I think? Seems that the loop here could hide potential problems.

    laanwj commented at 11:42 am on April 8, 2016:
    Right, there can’t be holes between DB_COINS records, will change this loop.
  13. in src/txdb.cpp: in eacf28cb38 outdated
    176+            return;
    177     }
    178-    stats.hashSerialized = ss.GetHash();
    179-    stats.nTotalAmount = nTotalAmount;
    180-    return true;
    181+    keyTmp.first = 0; // Invalidate cached key after last record so that GetKey() returns false
    


    sipa commented at 2:53 pm on April 6, 2016:
    Unreachable code?
  14. laanwj commented at 8:14 am on April 9, 2016: member
    Pushed a commit that should address @sipa’s comment: get rid of loop, no more chance of hiding failures.
  15. laanwj force-pushed on Apr 9, 2016
  16. sipa commented at 5:59 pm on April 12, 2016: member
    utACK 299fad9
  17. txdb: Add Cursor() method to CCoinsView to iterate over UTXO set
    Add a method Cursor() to CCoinsView that returns a cursor which can be
    used to iterate over the whole UTXO set.
    
    - rpc: Change gettxoutsetinfo to use new Cursor method
    
    - txdb: Remove GetStats method - Now that GetStats is implemented in
      terms of Cursor, remove it.
    509cb006d5
  18. laanwj force-pushed on Apr 15, 2016
  19. laanwj commented at 2:33 pm on April 15, 2016: member
    Squashed eacf28c 299fad9 into 509cb00
  20. laanwj merged this on Apr 15, 2016
  21. laanwj closed this on Apr 15, 2016

  22. laanwj referenced this in commit 9e47fcec17 on Apr 15, 2016
  23. laanwj referenced this in commit a3310b4d48 on Apr 18, 2016
  24. laanwj referenced this in commit 2498324ff9 on Sep 28, 2016
  25. codablock referenced this in commit 3a12fd5395 on Sep 16, 2017
  26. codablock referenced this in commit a6435a56a4 on Sep 19, 2017
  27. codablock referenced this in commit e0e44d0e45 on Sep 27, 2017
  28. codablock referenced this in commit 61a7485aae on Oct 12, 2017
  29. codablock referenced this in commit 23fe35a18a on Oct 19, 2017
  30. UdjinM6 referenced this in commit 7d9edd9d15 on Nov 8, 2017
  31. lateminer referenced this in commit 17d8ea7041 on Jan 12, 2018
  32. str4d referenced this in commit 4f3d6245d5 on Jan 27, 2018
  33. str4d referenced this in commit 9b1958bf06 on Mar 9, 2018
  34. str4d referenced this in commit 18752ec0ce on Mar 12, 2018
  35. str4d referenced this in commit 8b4e86b6d3 on Mar 15, 2018
  36. str4d referenced this in commit 9160285eea on Mar 30, 2018
  37. str4d referenced this in commit c602b06475 on Apr 4, 2018
  38. str4d referenced this in commit 06f21492d5 on May 31, 2018
  39. str4d referenced this in commit 9d3c1a7098 on Oct 24, 2018
  40. str4d referenced this in commit 06f3023ac1 on Jan 4, 2019
  41. str4d referenced this in commit 2705fea323 on Mar 14, 2019
  42. str4d referenced this in commit 9e893790c3 on Apr 2, 2019
  43. str4d referenced this in commit ffc99bbf49 on Apr 5, 2019
  44. str4d referenced this in commit 3647f0a7b1 on May 23, 2019
  45. milesmanley referenced this in commit aad9246f47 on Jun 22, 2019
  46. blondfrogs referenced this in commit 8156c70d30 on Jun 28, 2019
  47. milesmanley referenced this in commit 6ffd55e6b6 on Aug 27, 2019
  48. TheTrunk referenced this in commit 0d20c51843 on Aug 27, 2019
  49. random-zebra referenced this in commit b909e96121 on Aug 12, 2020
  50. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 21:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me