Bitcoin Forum
December 12, 2024, 04:53:11 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Can some explain long polling?  (Read 2536 times)
shads (OP)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 254


View Profile
June 17, 2011, 06: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?

PoolServerJ Home Page - High performance java mining pool engine

Quote from: Matthew N. Wright
Stop wasting the internet.
redhatzero
Full Member
***
Offline Offline

Activity: 126
Merit: 100



View Profile
June 17, 2011, 07: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

botnet
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
June 17, 2011, 06: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. 
pwnyboy
Full Member
***
Offline Offline

Activity: 125
Merit: 100


View Profile
June 17, 2011, 06: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.
shads (OP)
Sr. Member
****
Offline Offline

Activity: 266
Merit: 254


View Profile
June 18, 2011, 01:04:49 AM
 #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?

PoolServerJ Home Page - High performance java mining pool engine

Quote from: Matthew N. Wright
Stop wasting the internet.
1bitc0inplz
Member
**
Offline Offline

Activity: 112
Merit: 10


View Profile
June 18, 2011, 01:23:49 AM
 #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.

Mine @ http://pool.bitp.it - No fees, virtually 0 stales, what's not to love!
Chat with us @ #bitp.it on irc.freenode.net
Learn more about our pool @ http://forum.bitcoin.org/index.php?topic=12181.0
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!