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 AConnectionCurrent Connection to a Peer, may be null or a closed connection.protected static final org.slf4j.Loggerprotected InetSocketAddressResult 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.voidclose()Disconnects the client from the network, closing the underlying connection.static ConvexRemoteconnect(InetSocketAddress peerAddress) static ConvexRemotestatic ConvexRemoteprotected voidconnectToPeer(InetSocketAddress peerAddress) Gets the remote address for this Convex client instanceGets the local Server instance, or null if not a local connectionbooleanChecks 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.voidrequestChallenge(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 voidsetConnection(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:ConvexGets the remote address for this Convex client instance- Specified by:
getHostAddressin 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:
InterruptedExceptionIOException
-
connectNIO
public static ConvexRemote connectNIO(InetSocketAddress sa) throws InterruptedException, IOException, TimeoutException -
reconnect
- Specified by:
reconnectin classConvex- Throws:
IOExceptionTimeoutExceptionInterruptedException
-
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:
isConnectedin classConvex- Returns:
- true if connected, false otherwise
-
acquireState
Description copied from class:ConvexGets 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:
acquireStatein classConvex- Returns:
- Future for consensus state
-
transact
Description copied from class:ConvexSubmits 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:ConvexSubmits a query to the Convex network, returning a Future once the query has been successfully queued. -
messageRaw
Description copied from class:ConvexSubmits raw message data to the Convex network, returning a Future for any Result- Specified by:
messageRawin classConvex- Parameters:
message- Raw message data- Returns:
- A Future for the result of the query
-
message
Description copied from class:ConvexSubmits a Message to the connected peer, returning a Future for any Result -
requestStatus
Description copied from class:ConvexSubmits a status request to the Convex network peer, returning a Future once the request has been successfully queued.- Specified by:
requestStatusin classConvex- Returns:
- A Future for the result of the requestStatus
-
requestChallenge
Description copied from class:ConvexRequest a challenge. This is request is made by any peer that needs to find out if another peer can be trusted.- Specified by:
requestChallengein 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:ConvexAttempts 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:
closein interfaceAutoCloseable- Specified by:
closein classConvex
-
toString
-
getLocalServer
Description copied from class:ConvexGets the local Server instance, or null if not a local connection- Overrides:
getLocalServerin classConvex- Returns:
- Server instance (or null)
-