Skip to content

Conversation

gavinandresen
Copy link
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"

@@ -227,6 +227,7 @@ bool AppInit2(int argc, char* argv[])
" -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port> (default: 8332)") + "\n" +
" -rpcallowip=<ip> \t\t " + _("Allow JSON-RPC connections from specified IP address") + "\n" +
" -rpcconnect=<ip> \t " + _("Send commands to node running on <ip> (default: 127.0.0.1)") + "\n" +
" -blocknotify=<cmd> " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@jgarzik
Copy link
Contributor

jgarzik commented Jan 6, 2012

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

@luke-jr
Copy link
Member

luke-jr commented Jan 11, 2012

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

@@ -1336,6 +1346,14 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
nTransactionsUpdated++;
printf("SetBestChain: new best=%s height=%d work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());

std::string strCmd = GetArg("-blocknotify", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fair enough

@gavinandresen
Copy link
Contributor Author

I removed this branch accidently-- restored.

gavinandresen added a commit that referenced this pull request Jan 12, 2012
-blocknotify : run a command when best-block changes
@gavinandresen gavinandresen merged commit 3f64fa1 into bitcoin:master Jan 12, 2012
coblee referenced this pull request in litecoin-project/litecoin Jul 17, 2012
-blocknotify : run a command when best-block changes
destenson pushed a commit to destenson/bitcoin--bitcoin that referenced this pull request Jun 26, 2016
…directories

 - Remove sudo: required
 - Use addons to install apt packages
 - Use pip to install pyzmq
 - Use wine package from precise, so running windows binary for test need to call via wine.

Closes bitcoin#743
ptschip pushed a commit to ptschip/bitcoin that referenced this pull request Aug 20, 2017
…1.1.1.0

Add BUcash 1.1.1.0 release notes
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants