Author

Topic: Can some explain long polling? (Read 2534 times)

member
Activity: 112
Merit: 10
June 17, 2011, 08:23:49 PM
#6
thanks for link, that makes it a lot clearer so I can get to work now... The only part I'm not clear on is this:

Quote
4) If all the nonce space is exhausted during calculation or 60 seconds passed since receiving the data, the miner should request new one by means of main connection. 60 seconds limit is set to allow adding new transactions into the block.

Does this mean that the long poll itself should be dropped and reconnected every 60 seconds?  Or is it only talking about the main connection.

Also the long poll request is basically identical to a getwork request except for the different URL and lack of timeout?

When the pool terminates the LP connection, it does so to specify that new work is available. What the pool does is sends fresh "getwork" to the miner and drops the connection. The miner then knows that they should stop working on any previous work, and only proceed with the new work. It also re-esthablishes a fresh LP connection to repeat the cycle.

The 60 second thing varies by miner. Many GPU miners, even on cards incapable of iterating the nonce range in 60 seconds, do multiple getworks per minute. All getwork occurs over normal connections, except getwork "pushed" to the mine when it's previous work is invalidated by the network finding a block.
sr. member
Activity: 266
Merit: 254
June 17, 2011, 08:04:49 PM
#5
thanks for link, that makes it a lot clearer so I can get to work now... The only part I'm not clear on is this:

Quote
4) If all the nonce space is exhausted during calculation or 60 seconds passed since receiving the data, the miner should request new one by means of main connection. 60 seconds limit is set to allow adding new transactions into the block.

Does this mean that the long poll itself should be dropped and reconnected every 60 seconds?  Or is it only talking about the main connection.

Also the long poll request is basically identical to a getwork request except for the different URL and lack of timeout?
full member
Activity: 125
Merit: 100
June 17, 2011, 01:26:48 PM
#4
It's basically as the OP described - a persistent HTTP connection that is held open until the global blockchain increments.  At that point, the long polling server sends back a getwork response for the new block and closes the connection.  It's fairly easy to get sample data; just fire up Phoenix or poclbm in Linux and run tcpdump.
newbie
Activity: 35
Merit: 0
June 17, 2011, 01:15:59 PM
#3
http://en.wikipedia.org/wiki/Comet_(programming)

it's still a polling model for data, but the server holds the connection open until there is new data or it times out. 
full member
Activity: 126
Merit: 100
June 17, 2011, 02:00:43 AM
#2
I think deepbit has a good documentation of LP somewhere on their site.
Basically it's a http connection, you open it and then it's blocking until a new block is found. When a new block is found it returns the same stuff as a getwork would have done.

That's the whole magic
sr. member
Activity: 266
Merit: 254
June 17, 2011, 01:50:24 AM
#1
I've searched a lot but not really found an explanation of what it is or how it works.

I'm keen to get to work on a java implementation of a pool server.  It sounds to me like it's some sort of persistent HTTP connection that allows the server to push a message back to the client sometime after the getwork response has been sent to inform them that the block is finished and they need to get some fresh work to do. Is that the basic idea?

If so is there any doco or spec for it so I can make sure my pool server implements it correctly?
Jump to: