Execute a command when best block changes (-blocknotify=<cmd>) #714

pull luke-jr wants to merge 1 commits into bitcoin:master from luke-jr:blknotify changing 2 files +76 −1
  1. luke-jr commented at 7:34 PM on December 19, 2011: member

    This supercedes pull request #555 in a more flexible manner, including Windows support.

    To get the same behaviour as: -blknotifypidfile=/path/to/some.pid Now you do: -blocknotify='kill -USR1 $(</path/to/some.pid)"

    You can also use this with multiple pidfiles on the command line, or with cURL to issue a web request.

  2. in src/main.cpp:None in df4881dd9c outdated
    1210 | @@ -1204,6 +1211,60 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
    1211 |      nTransactionsUpdated++;
    1212 |      printf("SetBestChain: new best=%s  height=%d  work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
    1213 |  
    1214 | +    if (!fInitialDownload)
    1215 | +    {
    1216 | +        // Support block notification
    1217 | +        string strCmd = mapArgs["-blknotify"];
    1218 | +        if(strCmd != "")
    


    gavinandresen commented at 8:08 PM on December 19, 2011:

    Two nits: space between if and paren. And using GetArg("-blknotify", "") instead of indexing into mapArgs is probably a good idea for when we add a "getargs" RPC command to dump out the contents of mapArgs (indexing directly into mapArgs will add an empty string to it even if the user never specifies -blknotify at all).

  3. in src/main.cpp:None in 9f1d3214f7 outdated
    1210 | @@ -1204,6 +1211,60 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
    1211 |      nTransactionsUpdated++;
    1212 |      printf("SetBestChain: new best=%s  height=%d  work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
    1213 |  
    1214 | +    if (!fInitialDownload)
    1215 | +    {
    1216 | +        // Support block notification
    1217 | +        std::string strCmd = GetArg("-blknotify", "");
    


    gavinandresen commented at 4:59 PM on December 23, 2011:

    -blocknotify, yes?


    luke-jr commented at 5:10 PM on December 23, 2011:

    Good catch. Fixed.

  4. makomk commented at 12:46 PM on January 1, 2012: none

    On Linux, this leaks a zombie process every time the best block changes, which is probably going to result in PID exhaustion and stuff breaking eventually. Try for example 578e6df8827b74c97a2553b04a6d445ae7628b34 in addition.

  5. Execute a command when best block changes (-blocknotify=<cmd>) 7546ad986f
  6. luke-jr commented at 2:04 AM on January 2, 2012: member

    Good catch. Fixed the most graceful way I could find: by detatching the blocknotify process.

    I avoided SIGCHLD since it has the potential to not play nice with other stuff.

  7. luke-jr commented at 8:58 PM on January 3, 2012: member

    Superceded by #743

  8. luke-jr closed this on Jan 3, 2012

  9. destenson referenced this in commit 3d4c56c19e on Jun 26, 2016
  10. destenson referenced this in commit d5023dd7d3 on Aug 8, 2017
  11. Losangelosgenetics referenced this in commit 49c84ac7c0 on Mar 12, 2020
  12. jnewbery referenced this in commit 85e7d06351 on Mar 17, 2020
  13. sipa referenced this in commit 4977ac14d3 on Mar 18, 2020
  14. sipa referenced this in commit 5bf7fb5baa on Mar 18, 2020
  15. sipa referenced this in commit fb2a05e468 on Mar 19, 2020
  16. sipa referenced this in commit 497fad6f09 on Mar 21, 2020
  17. sipa referenced this in commit eae016f117 on Mar 22, 2020
  18. sipa referenced this in commit 4e37a7c2cb on Mar 27, 2020
  19. jnewbery referenced this in commit 9696dea839 on Apr 16, 2020
  20. jnewbery referenced this in commit a541fd0e87 on Apr 19, 2020
  21. sipa referenced this in commit c308759ea5 on Apr 19, 2020
  22. sipa referenced this in commit 4eaec32f1c on May 2, 2020
  23. sipa referenced this in commit ef7117193c on May 22, 2020
  24. sipa referenced this in commit 67f232b5d8 on Jun 9, 2020
  25. stackman27 referenced this in commit 78cde6f8c7 on Jun 26, 2020
  26. 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: 2026-04-14 15:16 UTC

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