Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Use service mask to find getutxo supporting peers instead of version
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehearn committed Jan 9, 2015
1 parent 08fe61a commit e4eb05d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion client/src/main/java/lighthouse/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ private void setupPeerGroup() {
// to randomly merge their answers and reduce the influence of any one seed. Additionally if
// more people run Bitcoin XT nodes we can bump up the number we search for here to again
// reduce the influence of any one node. But this needs people to help decentralise.


// TODO: This logic isn't right.

PeerDiscovery disco = new HttpDiscovery(params,
unchecked(() -> new URI("http://main.seed.vinumeris.com:8081/peers?srvmask=3&getutxo=true")),
// auth key used to sign responses.
Expand All @@ -400,7 +404,7 @@ private void setupPeerGroup() {
vPeerGroup.addPeerDiscovery(disco);
vPeerGroup.setMaxConnections(2);
vPeerGroup.setConnectTimeoutMillis(10000);
vPeerGroup.waitForPeersOfVersion(2, GetUTXOsMessage.MIN_PROTOCOL_VERSION).addListener(() -> {
vPeerGroup.waitForPeersWithServiceMask(2, GetUTXOsMessage.SERVICE_FLAGS_REQUIRED).addListener(() -> {
vPeerGroup.addPeerDiscovery(new DnsDiscovery(params));
vPeerGroup.setMaxConnections(6);
// Six peers is a tradeoff between reliability, trust and need to be gentle with network
Expand Down
5 changes: 2 additions & 3 deletions server/src/main/java/lighthouse/server/PledgeServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ public static void main(String[] args) throws Exception {
log.info("bitcoinj initialised");

// Don't start up fully until we're properly set up. Eventually this can go away.
// TODO: Make this also check for NODE_GETUTXOS flag.
log.info("Waiting to find a peer that supports getutxo");
kit.peerGroup().waitForPeersOfVersion(minPeersSupportingGetUTXO, GetUTXOsMessage.MIN_PROTOCOL_VERSION).get();
log.info("Waiting to find {} peer(s) that supports getutxo", minPeersSupportingGetUTXO);
kit.peerGroup().waitForPeersWithServiceMask(minPeersSupportingGetUTXO, GetUTXOsMessage.SERVICE_FLAGS_REQUIRED).get();
log.info("Found ... starting web server on port {}", portFlag.value(options));

// This app is mostly single threaded. It handles all requests and state changes on a single thread.
Expand Down

0 comments on commit e4eb05d

Please sign in to comment.