Add CChain object for headers-only chain #10894

pull jonasschnelli wants to merge 1 commits into bitcoin:master from jonasschnelli:2017/07/hdr_chain changing 4 files +14 −2
  1. jonasschnelli commented at 1:57 pm on July 21, 2017: contributor

    This PR introduces a CChain object for the headers chain. It allows to better inspect the headers chain (things like reorg detection). It would simplify a lot of things for a possible light client (SPV) mode.

    Slightly improves the headers-chain fork reporting in getchaintips.

  2. Add CChain object for headers-only chain 890c935d18
  3. jonasschnelli added the label Block storage on Jul 21, 2017
  4. jonasschnelli added this to the "In progress" column in a project

  5. in src/validation.cpp:2617 in 890c935d18
    2613@@ -2613,7 +2614,10 @@ static CBlockIndex* AddToBlockIndex(const CBlockHeader& block)
    2614     pindexNew->nChainWork = (pindexNew->pprev ? pindexNew->pprev->nChainWork : 0) + GetBlockProof(*pindexNew);
    2615     pindexNew->RaiseValidity(BLOCK_VALID_TREE);
    2616     if (pindexBestHeader == NULL || pindexBestHeader->nChainWork < pindexNew->nChainWork)
    2617+    {
    


    meshcollider commented at 7:52 pm on July 21, 2017:
    Nit, brace on new line
  6. in src/validation.cpp:3490 in 890c935d18
    3486@@ -3483,7 +3487,10 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
    3487         if (pindex->pprev)
    3488             pindex->BuildSkip();
    3489         if (pindex->IsValid(BLOCK_VALID_TREE) && (pindexBestHeader == NULL || CBlockIndexWorkComparator()(pindexBestHeader, pindex)))
    3490+        {
    


    meshcollider commented at 7:52 pm on July 21, 2017:
    Same here
  7. meshcollider commented at 7:53 pm on July 21, 2017: contributor
  8. sipa commented at 8:00 pm on July 21, 2017: member
    It is unnecessary to add a new CChain object (3.5 MiB of RAM) for this. You can test whether pindex is an ancestor of pindexBestHeader using ‘pindexBestHeader->GetAncestor(pindex->nHeight) == pindex`.
  9. jonasschnelli commented at 7:16 am on July 24, 2017: contributor
    @sipa: For the light client headers based fork detection the FindFork() method would be very handy. Maybe have a look at the “sketch” SPV code for the wallet: https://github.com/bitcoin/bitcoin/pull/9483/files#diff-b2bb174788c7409b671c46ccc86034bdR1182
  10. jonasschnelli commented at 7:17 am on July 24, 2017: contributor
    If one runs in full non validation mode (light client mode), the memory consumption would be ~the same, because only the headers chain will require memory (the chainActive will be empty).
  11. sipa commented at 7:47 am on July 24, 2017: member
    @jonasschnelli You can use FindCommonAncestor between two CBlockIndex objects if you don’t have a CChain, instead of FindFork.
  12. jonasschnelli commented at 8:41 am on July 24, 2017: contributor
    Thanks @sipa. Makes sense. Closing for now.
  13. jonasschnelli closed this on Jul 24, 2017

  14. danra commented at 3:25 pm on September 30, 2017: contributor
    @jonasschnelli @sipa If this is no longer relevant I suggest removing it from the “Client-Mode (SPV)” project to reduce noise (especially since there are already two other, somewhat overlapping, PRs in the project)
  15. jonasschnelli removed this from the "In progress" column in a project

  16. DrahtBot 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-10-31 03:12 UTC

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