Ejemplo n.º 1
0
 protected InboundMessageQueuer connectPeerWithoutVersionExchange(int id) throws Exception {
   Preconditions.checkArgument(id < PEER_SERVERS);
   InetSocketAddress remoteAddress = new InetSocketAddress("127.0.0.1", 2000 + id);
   Peer peer = peerGroup.connectTo(remoteAddress).getConnectionOpenFuture().get();
   InboundMessageQueuer writeTarget = newPeerWriteTargetQueue.take();
   writeTarget.peer = peer;
   return writeTarget;
 }
Ejemplo n.º 2
0
 private void stepThroughInit(VersionMessage versionMessage, InboundMessageQueuer writeTarget)
     throws InterruptedException {
   checkState(writeTarget.nextMessageBlocking() instanceof VersionMessage);
   checkState(writeTarget.nextMessageBlocking() instanceof VersionAck);
   if (versionMessage.isBloomFilteringSupported()) {
     checkState(writeTarget.nextMessageBlocking() instanceof BloomFilter);
     checkState(writeTarget.nextMessageBlocking() instanceof MemoryPoolMessage);
   }
 }
Ejemplo n.º 3
0
 // handle peer discovered by PeerGroup
 protected InboundMessageQueuer handleConnectToPeer(int id, VersionMessage versionMessage)
     throws Exception {
   InboundMessageQueuer writeTarget = newPeerWriteTargetQueue.take();
   checkArgument(versionMessage.hasBlockChain());
   // Complete handshake with the peer - send/receive version(ack)s, receive bloom filter
   writeTarget.sendMessage(versionMessage);
   writeTarget.sendMessage(new VersionAck());
   stepThroughInit(versionMessage, writeTarget);
   return writeTarget;
 }
Ejemplo n.º 4
0
 protected InboundMessageQueuer connectPeer(int id, VersionMessage versionMessage)
     throws Exception {
   checkArgument(versionMessage.hasBlockChain());
   InboundMessageQueuer writeTarget = connectPeerWithoutVersionExchange(id);
   // Complete handshake with the peer - send/receive version(ack)s, receive bloom filter
   writeTarget.sendMessage(versionMessage);
   writeTarget.sendMessage(new VersionAck());
   stepThroughInit(versionMessage, writeTarget);
   return writeTarget;
 }