-blocknotify : run a command when best-block changes #743

pull gavinandresen wants to merge 1 commits into bitcoin:master from gavinandresen:blocknotify changing 2 files +20 −1
  1. gavinandresen commented at 8:53 PM on January 3, 2012: contributor

    This re-implements pull#714, using system() (which does work on Windows) and boost::thread().

    Help text is: -blocknotify=<cmd> Execute command when the best block changes (%s in cmd is replaced by block hash)

    Example usage (this is how I tested):

    ./bitcoind -blocknotify="./bitcoind getblock %s >> /tmp/blocks.txt"

  2. -blocknotify=command argument, implemented using system() and boost::thread d237f62c23
  3. in src/init.cpp:None in d237f62c23
     226 | @@ -227,6 +227,7 @@ bool AppInit2(int argc, char* argv[])
     227 |              "  -rpcport=<port>  \t\t  " + _("Listen for JSON-RPC connections on <port> (default: 8332)") + "\n" +
     228 |              "  -rpcallowip=<ip> \t\t  " + _("Allow JSON-RPC connections from specified IP address") + "\n" +
     229 |              "  -rpcconnect=<ip> \t  "   + _("Send commands to node running on <ip> (default: 127.0.0.1)") + "\n" +
     230 | +            "  -blocknotify=<cmd> "     + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" +
    


    luke-jr commented at 8:57 PM on January 3, 2012:

    This is too long for standard terminals (79 chars wide), and doesn't fit with the style used by the other options (minimum two spaces between parameter and description).

  4. jgarzik commented at 4:31 PM on January 6, 2012: contributor

    visual ACK (== I did not build or test it, only a github conceptual review)

  5. luke-jr commented at 10:07 PM on January 11, 2012: member

    Gavin, this branch is missing in your repo...?

  6. in src/main.cpp:None in d237f62c23
    1345 | @@ -1336,6 +1346,14 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
    1346 |      nTransactionsUpdated++;
    1347 |      printf("SetBestChain: new best=%s  height=%d  work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
    1348 |  
    1349 | +    std::string strCmd = GetArg("-blocknotify", "");
    


    laanwj commented at 10:25 PM on January 11, 2012:

    I think it'd be somewhat cleaner to make strCmd a global, and fill it in init.cpp, so that GetArgs happen in the one function as much as possible, and not parsed every time.


    gavinandresen commented at 11:31 PM on January 11, 2012:

    A global puts the information in two places (the mapArgs array and the global), which I think would be a mistake-- if the information is in two places, then then it is possible that those two places will get ouf of sync.

    I also like being able to grep for the command-line option to find all the code that deals with that option.

    There is no possible performance issue, since blocknotify will trigger once every 10 minutes.


    laanwj commented at 8:14 AM on January 12, 2012:

    Ok, fair enough

  7. gavinandresen commented at 11:31 PM on January 11, 2012: contributor

    I removed this branch accidently-- restored.

  8. gavinandresen referenced this in commit 3f64fa1369 on Jan 12, 2012
  9. gavinandresen merged this on Jan 12, 2012
  10. gavinandresen closed this on Jan 12, 2012

  11. coblee referenced this in commit f54e997bb8 on Jul 17, 2012
  12. destenson referenced this in commit 91b2546d8b on Jun 26, 2016
  13. ptschip referenced this in commit c0c02dfa0f on Aug 20, 2017
  14. 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 18:16 UTC

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