saifi009 / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
0 stars 0 forks source link

Patch to specify timeout for peer connections and PingServiceIrcPeer example. #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There is no network timeout parameter when trying to connect to peers.
I'm not sure what the java default is but its long. Over a minute as far as I 
can tell. 

Not an issue when you are only connecting to localhost but when you have to go 
through a list of potential peers before one will let you connect it causes a 
problem.

This patch changes NetworkConnection to accept a connection timeout parameter 
(milliseconds).

Also included is examples/PingServiceIrcPeer which demos the PingService 
connecting to a discovered peer with a 5 second timeout. 
(5 seconds is still probably too long to wait before trying another)

examples/PingService and PrivateKeys were modified to use the timeout parameter.

(Obviously this patch should not be applied unless the PeerDiscovery patch is 
applied first)

Original issue reported on code.google.com by jwsam...@gmail.com on 29 Apr 2011 at 2:13

Attachments:

GoogleCodeExporter commented 9 years ago
Shouldn't be labeled as a defect but I can't change it now.

Original comment by jwsam...@gmail.com on 29 Apr 2011 at 2:14

GoogleCodeExporter commented 9 years ago
Thanks. I'll take a look at these two changes early next week. I took a quick 
look at the IRC patch and it looked great. 

One minor thing - the Google style guide requires grammatically correct 
comments (capital letters, full stops etc). It might seem ridiculous, at least 
it did to me at first, but I find it really helps get you in the right frame of 
mind for writing comments.

You don't have to worry about it this time, I'll go through and fix them up 
after commit.

Original comment by hearn@google.com on 29 Apr 2011 at 9:14

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r65.

Original comment by hearn@google.com on 2 May 2011 at 11:59

GoogleCodeExporter commented 9 years ago
Thanks again.

I didn't check in the IrcPeers sample. I think the PingService should be an 
example of how to use the APIs from a users perspective. Clearly, finding 
active peers should be happening inside BitCoinJ itself in the discussed 
PeerGroup abstraction, so this additional example would just be a distraction 
to people learning the code.

Original comment by hearn@google.com on 2 May 2011 at 11:59