java.lang.Object
convex.api.Convex
convex.api.ConvexRemote
- All Implemented Interfaces:
AutoCloseable
Convex client API implementation for peers accessed over a network connection using the Convex binary peer protocol
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AConnection
Current Connection to a Peer, may be null or a closed connection.protected static final org.slf4j.Logger
protected InetSocketAddress
Result handler for Messages received back from a remote connection -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends ACell>
CompletableFuture<T> Attempts to acquire a complete persistent data structure for the given hash from the connected peer.Gets the consensus state from the connected Peer.void
close()
Disconnects the client from the network, closing the underlying connection.static ConvexRemote
connect
(InetSocketAddress peerAddress) static ConvexRemote
static ConvexRemote
protected void
connectToPeer
(InetSocketAddress peerAddress) Gets the remote address for this Convex client instanceGets the local Server instance, or null if not a local connectionboolean
Checks if this Convex client instance has an open remote connection.Submits a Message to the connected peer, returning a Future for any ResultmessageRaw
(Blob message) Submits raw message data to the Convex network, returning a Future for any ResultSubmits a query to the Convex network, returning a Future once the query has been successfully queued.void
requestChallenge
(SignedData<ACell> data) Request a challenge.Submits a status request to the Convex network peer, returning a Future once the request has been successfully queued.protected void
setConnection
(AConnection conn) Sets the current Connection for this Remote ClienttoString()
transact
(SignedData<ATransaction> signed) Submits a signed transaction to the Convex network, returning a Future once the transaction has been successfully queued.Methods inherited from class convex.api.Convex
acquire, clearSequence, connect, connect, connect, connect, createAccount, createAccountSync, finalize, getAccountKey, getAccountKey, getAddress, getBalance, getBalance, getKeyPair, getNextID, getSequence, getSequence, getTimeout, isAutoSequence, isPreCompile, lookupSequence, maybeUpdateSequence, preCompile, prepareTransaction, prepareTransaction, query, query, querySync, querySync, querySync, querySync, requestStatusSync, requestStatusSync, resolve, setAddress, setAddress, setAutoSequence, setKeyPair, setNextSequence, setPreCompile, setTimeout, signData, transact, transact, transact, transactSync, transactSync, transactSync, transactSync, transactSync, transfer, transferSync
-
Field Details
-
connection
Current Connection to a Peer, may be null or a closed connection. -
log
protected static final org.slf4j.Logger log -
remoteAddress
-
returnMessageHandler
Result handler for Messages received back from a remote connection
-
-
Constructor Details
-
ConvexRemote
-
-
Method Details
-
getHostAddress
Description copied from class:Convex
Gets the remote address for this Convex client instance- Specified by:
getHostAddress
in classConvex
- Returns:
- Socket address
-
connectToPeer
protected void connectToPeer(InetSocketAddress peerAddress) throws IOException, TimeoutException, InterruptedException -
connect
public static ConvexRemote connect(InetSocketAddress peerAddress) throws IOException, TimeoutException, InterruptedException -
connectNetty
public static ConvexRemote connectNetty(InetSocketAddress sa) throws InterruptedException, IOException - Throws:
InterruptedException
IOException
-
connectNIO
public static ConvexRemote connectNIO(InetSocketAddress sa) throws InterruptedException, IOException, TimeoutException -
reconnect
- Specified by:
reconnect
in classConvex
- Throws:
IOException
TimeoutException
InterruptedException
-
setConnection
Sets the current Connection for this Remote Client- Parameters:
conn
- Connection value to use
-
isConnected
public boolean isConnected()Checks if this Convex client instance has an open remote connection.- Specified by:
isConnected
in classConvex
- Returns:
- true if connected, false otherwise
-
acquireState
Description copied from class:Convex
Gets the consensus state from the connected Peer. The acquired state will be a snapshot of the network global state as calculated by the Peer. SECURITY: Be aware that if this client instance is connected to an untrusted Peer, the Peer may lie about the latest state. If this is a security concern, the client should validate the consensus state independently.- Overrides:
acquireState
in classConvex
- Returns:
- Future for consensus state
-
transact
Description copied from class:Convex
Submits a signed transaction to the Convex network, returning a Future once the transaction has been successfully queued. Updates cached sequence number on best effort basis. -
query
Description copied from class:Convex
Submits a query to the Convex network, returning a Future once the query has been successfully queued. -
messageRaw
Description copied from class:Convex
Submits raw message data to the Convex network, returning a Future for any Result- Specified by:
messageRaw
in classConvex
- Parameters:
message
- Raw message data- Returns:
- A Future for the result of the query
-
message
Description copied from class:Convex
Submits a Message to the connected peer, returning a Future for any Result -
requestStatus
Description copied from class:Convex
Submits a status request to the Convex network peer, returning a Future once the request has been successfully queued.- Specified by:
requestStatus
in classConvex
- Returns:
- A Future for the result of the requestStatus
-
requestChallenge
Description copied from class:Convex
Request a challenge. This is request is made by any peer that needs to find out if another peer can be trusted.- Specified by:
requestChallenge
in classConvex
- Parameters:
data
- Signed data to send to the peer for the challenge.- Returns:
- A Future for the result of the requestChallenge
-
acquire
Description copied from class:Convex
Attempts to acquire a complete persistent data structure for the given hash from the connected peer. Uses the store provided as a destination. -
close
public void close()Disconnects the client from the network, closing the underlying connection.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in classConvex
-
toString
-
getLocalServer
Description copied from class:Convex
Gets the local Server instance, or null if not a local connection- Overrides:
getLocalServer
in classConvex
- Returns:
- Server instance (or null)
-