private final int port;
private final AtomicReference<FcpConnection> fcpConnection = new AtomicReference<>();
private final Supplier<String> clientName;
- private final Supplier<String> expectedVersion;
- public DefaultFcpClient(ExecutorService threadPool, String hostname, int port, Supplier<String> clientName,
- Supplier<String> expectedVersion) {
+ public DefaultFcpClient(ExecutorService threadPool, String hostname, int port, Supplier<String> clientName) {
this.threadPool = MoreExecutors.listeningDecorator(threadPool);
this.hostname = hostname;
this.port = port;
this.clientName = clientName;
- this.expectedVersion = expectedVersion;
}
private FcpConnection connect() throws IOException {
FcpConnection connection = new FcpConnection(hostname, port);
connection.connect();
FcpReplySequence<?> nodeHelloSequence = new ClientHelloReplySequence(connection);
- ClientHello clientHello = new ClientHello(clientName.get(), expectedVersion.get());
+ ClientHello clientHello = new ClientHello(clientName.get(), "2.0");
try {
nodeHelloSequence.send(clientHello).get();
} catch (InterruptedException | ExecutionException e) {
return new ClientPutCommandImpl(threadPool, this::connect);
}
+ @Override
+ public ListPeersCommand listPeers() {
+ return new ListPeersCommandImpl(threadPool, this::connect);
+ }
+
private class ClientHelloReplySequence extends FcpReplySequence<Void> {
private final AtomicReference<NodeHello> receivedNodeHello;