/** Sends a getaddr request to the peer and returns a future that completes with the answer once the peer has replied. */ public ListenableFuture<AddressMessage> getAddr() { SettableFuture<AddressMessage> future = SettableFuture.create(); synchronized (getAddrFutures) { getAddrFutures.add(future); } sendMessage(new GetAddrMessage(params)); return future; }
/** Sends a getaddr request to the peer and returns a future that completes with the answer once the peer has replied. */ public ListenableFuture<AddressMessage> getAddr() { SettableFuture<AddressMessage> future = SettableFuture.create(); synchronized (getAddrFutures) { getAddrFutures.add(future); } sendMessage(new GetAddrMessage(params)); return future; }
/** Sends a getaddr request to the peer and returns a future that completes with the answer once the peer has replied. */ public ListenableFuture<AddressMessage> getAddr() { SettableFuture<AddressMessage> future = SettableFuture.create(); synchronized (getAddrFutures) { getAddrFutures.add(future); } sendMessage(new GetAddrMessage(params)); return future; }
/** Sends a getaddr request to the peer and returns a future that completes with the answer once the peer has replied. */ public ListenableFuture<AddressMessage> getAddr() { SettableFuture<AddressMessage> future = SettableFuture.create(); synchronized (getAddrFutures) { getAddrFutures.add(future); } sendMessage(new GetAddrMessage(params)); return future; }
@Override public void connectionOpened() { // Announce ourselves. This has to come first to connect to clients beyond v0.3.20.2 which wait to hear // from us until they send their version message back. PeerAddress address = getAddress(); log.info("Announcing to {} as: {}", address == null ? "Peer" : address.toSocketAddress(), versionMessage.subVer); sendMessage(versionMessage); connectionOpenFuture.set(this); // When connecting, the remote peer sends us a version message with various bits of // useful data in it. We need to know the peer protocol version before we can talk to it. }
@Override public void connectionOpened() { // Announce ourselves. This has to come first to connect to clients beyond v0.3.20.2 which wait to hear // from us until they send their version message back. PeerAddress address = getAddress(); log.info("Announcing to {} as: {}", address == null ? "Peer" : address.toSocketAddress(), versionMessage.subVer); sendMessage(versionMessage); connectionOpenFuture.set(this); // When connecting, the remote peer sends us a version message with various bits of // useful data in it. We need to know the peer protocol version before we can talk to it. }
@Override public void connectionOpened() { // Announce ourselves. This has to come first to connect to clients beyond v0.3.20.2 which wait to hear // from us until they send their version message back. PeerAddress address = getAddress(); log.info("Announcing to {} as: {}", address == null ? "Peer" : address.toSocketAddress(), versionMessage.subVer); sendMessage(versionMessage); connectionOpenFuture.set(this); // When connecting, the remote peer sends us a version message with various bits of // useful data in it. We need to know the peer protocol version before we can talk to it. }
@Override public void connectionOpened() { // Announce ourselves. This has to come first to connect to clients beyond v0.3.20.2 which wait to hear // from us until they send their version message back. PeerAddress address = getAddress(); log.info("Announcing to {} as: {}", address == null ? "Peer" : address.toSocketAddress(), versionMessage.subVer); sendMessage(versionMessage); connectionOpenFuture.set(this); // When connecting, the remote peer sends us a version message with various bits of // useful data in it. We need to know the peer protocol version before we can talk to it. }
/** Sends a getdata with a single item in it. */ private ListenableFuture sendSingleGetData(GetDataMessage getdata) { // This does not need to be locked. Preconditions.checkArgument(getdata.getItems().size() == 1); GetDataRequest req = new GetDataRequest(getdata.getItems().get(0).hash, SettableFuture.create()); getDataFutures.add(req); sendMessage(getdata); return req.future; }
/** Sends a getdata with a single item in it. */ private ListenableFuture sendSingleGetData(GetDataMessage getdata) { // This does not need to be locked. Preconditions.checkArgument(getdata.getItems().size() == 1); GetDataRequest req = new GetDataRequest(getdata.getItems().get(0).hash, SettableFuture.create()); getDataFutures.add(req); sendMessage(getdata); return req.future; }
/** Sends a getdata with a single item in it. */ private ListenableFuture sendSingleGetData(GetDataMessage getdata) { // This does not need to be locked. Preconditions.checkArgument(getdata.getItems().size() == 1); GetDataRequest req = new GetDataRequest(getdata.getItems().get(0).hash, SettableFuture.create()); getDataFutures.add(req); sendMessage(getdata); return req.future; }
/** Sends a getdata with a single item in it. */ private ListenableFuture sendSingleGetData(GetDataMessage getdata) { // This does not need to be locked. Preconditions.checkArgument(getdata.getItems().size() == 1); GetDataRequest req = new GetDataRequest(getdata.getItems().get(0).hash, SettableFuture.create()); getDataFutures.add(req); sendMessage(getdata); return req.future; }
protected ListenableFuture<Long> ping(long nonce) throws ProtocolException { final VersionMessage ver = vPeerVersionMessage; if (!ver.isPingPongSupported()) throw new ProtocolException("Peer version is too low for measurable pings: " + ver); PendingPing pendingPing = new PendingPing(nonce); pendingPings.add(pendingPing); sendMessage(new Ping(pendingPing.nonce)); return pendingPing.future; }
protected ListenableFuture<Long> ping(long nonce) throws ProtocolException { final VersionMessage ver = vPeerVersionMessage; if (!ver.isPingPongSupported()) throw new ProtocolException("Peer version is too low for measurable pings: " + ver); PendingPing pendingPing = new PendingPing(nonce); pendingPings.add(pendingPing); sendMessage(new Ping(pendingPing.nonce)); return pendingPing.future; }
protected ListenableFuture<Long> ping(long nonce) throws ProtocolException { final VersionMessage ver = vPeerVersionMessage; if (!ver.isPingPongSupported()) throw new ProtocolException("Peer version is too low for measurable pings: " + ver); PendingPing pendingPing = new PendingPing(nonce); pendingPings.add(pendingPing); sendMessage(new Ping(pendingPing.nonce)); return pendingPing.future; }
protected ListenableFuture<Long> ping(long nonce) throws ProtocolException { final VersionMessage ver = vPeerVersionMessage; if (!ver.isPingPongSupported()) throw new ProtocolException("Peer version is too low for measurable pings: " + ver); PendingPing pendingPing = new PendingPing(nonce); pendingPings.add(pendingPing); sendMessage(new Ping(pendingPing.nonce)); return pendingPing.future; }
private void processPing(Ping m) { if (m.hasNonce()) sendMessage(new Pong(m.getNonce())); }
private void processPing(Ping m) { if (m.hasNonce()) sendMessage(new Pong(m.getNonce())); }
private void processPing(Ping m) { if (m.hasNonce()) sendMessage(new Pong(m.getNonce())); }
private void outboundPingAndWait(final InboundMessageQueuer p, long nonce) throws Exception { // Send a ping and wait for it to get to the other side SettableFuture<Void> pingReceivedFuture = SettableFuture.create(); p.mapPingFutures.put(nonce, pingReceivedFuture); p.peer.sendMessage(new Ping(nonce)); pingReceivedFuture.get(); p.mapPingFutures.remove(nonce); }