Minor changes to dbwrapper to simplify support for other databases #7927

pull laanwj wants to merge 4 commits into bitcoin:master from laanwj:2016_04_dbwrapper_modernization changing 4 files +73 −68
  1. laanwj commented at 7:37 AM on April 23, 2016: member

    During my experiment with using LMDB as database I came across these database-agnostic changes to dbwrapper which make it easier to support other databases, or are small common-sense (I think) cleanups at most:

    • Pass parent CDBWrapper into CDBBatch and CDBIterator instead of obfuscation key (in the case of lmdb the batch needs to know about the database, to create a write transaction). This also looks cleaner.
    • Incrase privacy of methods that are implementation specific by moving them to a namespace: HandleError, GetObfuscateKey.
    • Make constructor of CDBIterator private - they rely on implementation details, others have no business instantiating these.
    • Remove GetObfuscateKeyHex - It is an unnecessary method as it is used only two times and only internally, and the whole implementation is HexStr(obfuscate_key).
    • Remove throw keywords in function signatures - Using throw() specifications in function signatures is not only not required in C++, it is considered deprecated for various reasons. It is not implemented by any of the common C++ compilers. Their usage is also inconsistent with the rest of the source code.
  2. dbwrapper: Remove throw keywords in function signatures
    Using throw() specifications in function signatures is not only
    not required in C++, it is considered deprecated for
    [various reasons](https://stackoverflow.com/questions/1055387/throw-keyword-in-functions-signature).
    It is not implemented by any of the common C++ compilers. The usage is
    also inconsistent with the rest of the source code.
    74f7b1273c
  3. dbwrapper: Remove CDBWrapper::GetObfuscateKeyHex
    It is an unnecessary method as it is used only two times
    and only internally, and the whole implementation is
    HexStr(obfuscate_key).
    878bf480a3
  4. dbwrapper: Pass parent CDBWrapper into CDBBatch and CDBIterator
    Pass parent wrapper directly instead of obfuscation key. This
    makes it possible for other databases which re-use this code
    to use other properties from the database.
    
    Add a namespace dbwrapper_private for private functions to be used
    only in dbwrapper.h/cpp and dbwrapper_tests.
    b69836d6ff
  5. dbwrapper: Move `HandleError` to `dbwrapper_private`
    HandleError is implementation-specific.
    869cf1234a
  6. laanwj added the label UTXO Db and Indexes on Apr 23, 2016
  7. laanwj added the label Refactoring on Apr 23, 2016
  8. sipa commented at 1:27 PM on April 23, 2016: member

    utACK 869cf1234a915808fda6fd663dead5580fbd046e

  9. MarcoFalke commented at 1:46 PM on April 23, 2016: member

    utACK 869cf12

  10. btcdrak commented at 2:35 PM on April 23, 2016: contributor

    Tested ACK 869cf12

  11. paveljanik commented at 2:56 PM on April 23, 2016: contributor

    ACK https://github.com/bitcoin/bitcoin/commit/869cf1234a915808fda6fd663dead5580fbd046e

    throw() is still used in two other files on master:

    src/support/allocators/secure.h
    src/support/allocators/zeroafterfree.h
    

    but it is not for this PR.

  12. jonasschnelli commented at 4:54 PM on April 23, 2016: contributor

    utACK 869cf1234a915808fda6fd663dead5580fbd046e

  13. jamesob commented at 10:19 PM on April 23, 2016: member

    utACK

  14. laanwj commented at 10:39 AM on April 25, 2016: member

    throw() is still used in two other files on master:

    src/support/allocators/secure.h src/support/allocators/zeroafterfree.h

    Thanks for mentioning, although I think these are of a different class. They use throw() in the more conventional way to signify that a method or function doesn't ever throw. These could be replaced by the noexcept keyword in c++11.

  15. laanwj merged this on Apr 25, 2016
  16. laanwj closed this on Apr 25, 2016

  17. laanwj referenced this in commit f9c2ac7232 on Apr 25, 2016
  18. codablock referenced this in commit 230dd5d190 on Sep 16, 2017
  19. codablock referenced this in commit 7ebd87e48c on Sep 19, 2017
  20. codablock referenced this in commit 5b41c3b10b on Sep 27, 2017
  21. codablock referenced this in commit b2367353eb on Oct 12, 2017
  22. codablock referenced this in commit 2e54bd2e8c on Oct 19, 2017
  23. UdjinM6 referenced this in commit 1de0ab0d86 on Nov 8, 2017
  24. zkbot referenced this in commit 068e82e00a on Jan 15, 2018
  25. litecoinz-project referenced this in commit 6c18cc917a on Mar 15, 2018
  26. zkbot referenced this in commit 564119eb31 on Apr 3, 2018
  27. zkbot referenced this in commit 77669b952b on Apr 3, 2018
  28. random-zebra referenced this in commit 73d26f20e9 on May 27, 2020
  29. 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: 2026-04-13 15:15 UTC

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