[WIP] scripted-diff: Avoid name collisions in CChainState #15795

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:1904-m_chain changing 1 files +115 −115
  1. MarcoFalke commented at 5:02 PM on April 11, 2019: member

    This avoids name collisions between globals and member variables of the chainstate

  2. scripted-diff: Avoid name collisions in CChainState
    -BEGIN VERIFY SCRIPT-
    SRC=("chainActive" "mapBlockIndex" "mapBlocksUnlinked" "pindexBestInvalid")
    DST=("m_chain"     "m_block_index" "m_blocks_unlinked" "index_best_invalid")
    
     # Hand picked line ranges of CChainState member functions
     # Found with `git grep -n -p -W  'CChainState::'  | grep --extended-regexp ':[0-9]+:'   | sed --regexp-extended 's/src.validation.cpp.([0-9]+).*/\1/g' | tr '\n' ' '`
    MEMBER_FUN_BEGIN=(1296 1562 1773 2266 2386 2445 2500 2515 2636 2738 2770 2859 2897 2934 3327 3449 3776 3796 4043 4063 4133 4134 4169 4281 4338 4490)
     # Found with `git grep -n -p -W  'CChainState::'  | grep --extended-regexp '\-[0-9]+\-}'| sed --regexp-extended 's/src.validation.cpp.([0-9]+).*/\1/g' | tr '\n' ' '`
    MEMBER_FUN_END=(  1304 1617 2055 2310 2439 2497 2509 2596 2732 2765 2853 2891 2931 2978 3406 3526 3794 3844 4061 4127 4131 4167 4260 4285 4361 4672)
    
    for i in ${!DST[*]}
    do
     echo "Replace ${SRC[$i]} with ${DST[$i]} ..."
     sed -i -r -e "1,165{s/(    .+ \*?)${SRC[$i]}/\1${DST[$i]}/g}"   src/validation.cpp
     sed -i -e "s/g_chainstate.${SRC[$i]}/g_chainstate.${DST[$i]}/g" src/validation.cpp
    
     for j in ${!MEMBER_FUN_BEGIN[*]}
     do
      echo " ... from line ${MEMBER_FUN_BEGIN[$j]} to ${MEMBER_FUN_BEGIN[$j]}"
      sed -i -e "${MEMBER_FUN_BEGIN[$j]},${MEMBER_FUN_END[$j]}{s/\<${SRC[$i]}\>/${DST[$i]}/g}"  src/validation.cpp
     done
    done
    -END VERIFY SCRIPT-
    fa1d3ee8d8
  3. DrahtBot added the label Refactoring on Apr 11, 2019
  4. DrahtBot added the label Validation on Apr 11, 2019
  5. MarcoFalke renamed this:
    scripted-diff: Avoid name collisions in CChainState
    [WIP] scripted-diff: Avoid name collisions in CChainState
    on Apr 11, 2019
  6. jamesob commented at 5:19 PM on April 11, 2019: member

    This refactoring is motivated by #15606.

  7. MarcoFalke closed this on Apr 11, 2019

  8. MarcoFalke deleted the branch on Apr 11, 2019
  9. DrahtBot locked this on Dec 16, 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-17 06:14 UTC

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