On Fri, May 31, 2013 at 2:10 PM, Michael Hendricks <michael@ndrix.org> wrote:
On Fri, May 31, 2013 at 5:56 AM, Rune Kjær Svendsen <runesvend@gmail.com> wrote:
I have an application that wants to keep up with new blocks as they come in. For that I can use the -blocknotify option with bitcoind, which will execute my application for each new block.

The problem is that my app isn't necessarily quick enough to finish its work before a new block comes in and the app is executed again.

In a similar circumstance, I changed my -blocknotify script to quickly append necessary information to a queue and immediately exit.  A separate script runs at all times monitoring this queue for work and performs the labor intensive calculations.

I've thought about this as well. It just seems somewhat clunky to me. I'd really prefer having bitcoind put out messages in batches, if it's doable, that is.

I'd run into a lot of concurrency issues, as far as I can see, where I can't be sure that the queue isn't written to while, for example, it is opened by the program that needs to process the queue items.

What if a disk operation takes a long time to finish, and a two queue operations want to add to the queue simultaneously? This really brings forward all the horrors of concurrent programming.


On Fri, May 31, 2013 at 2:17 PM, Jeremy Spilman <jeremy@taplink.co> wrote:
Would it work to just block the bitcoind thread until your process exits?

I don't think that's optimal, no. That would slow down synchronization drastically.

It would be really nimble for bitcoind to be able to synchronize at full speed, and only send out events when necessary, batching together previously queued items.