Bitcoin Forum
December 08, 2016, 02:10:07 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Can some explain long polling?  (Read 2183 times)
shads
Full Member
***
Offline Offline

Activity: 224


View Profile WWW
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

1LezqRatQz7MeNoCVziYwcdwtqeEbvrdAq - http://payb.tc/shads

Quote from: Matthew N. Wright
Stop wasting the internet.
1481163007
Hero Member
*
Offline Offline

Posts: 1481163007

View Profile Personal Message (Offline)

Ignore
1481163007
Reply with quote  #2

1481163007
Report to moderator
1481163007
Hero Member
*
Offline Offline

Posts: 1481163007

View Profile Personal Message (Offline)

Ignore
1481163007
Reply with quote  #2

1481163007
Report to moderator
1481163007
Hero Member
*
Offline Offline

Posts: 1481163007

View Profile Personal Message (Offline)

Ignore
1481163007
Reply with quote  #2

1481163007
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481163007
Hero Member
*
Offline Offline

Posts: 1481163007

View Profile Personal Message (Offline)

Ignore
1481163007
Reply with quote  #2

1481163007
Report to moderator
1481163007
Hero Member
*
Offline Offline

Posts: 1481163007

View Profile Personal Message (Offline)

Ignore
1481163007
Reply with quote  #2

1481163007
Report to moderator
redhatzero
Full Member
***
Offline Offline

Activity: 126



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
Jr. Member
*
Offline Offline

Activity: 35


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


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
Full Member
***
Offline Offline

Activity: 224


View Profile WWW
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

1LezqRatQz7MeNoCVziYwcdwtqeEbvrdAq - http://payb.tc/shads

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

Activity: 112


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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!