Package convex.peer
Class API
java.lang.Object
convex.peer.API
Class providing a simple API to operate a peer protocol Server.
Suitable for library usage, e.g. if a user application wants to
instantiate a local network peer.
"If you don't believe it or don't get it , I don't have time to convince you"
- Satoshi Nakamoto
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isNetworkReady
(List<Server> serverList, long timeoutMillis) Returns a true value if the local network is ready and synced with the same consensus state hash.launchLocalPeers
(List<AKeyPair> keyPairs, State genesisState) Launch a local set of peers.launchLocalPeers
(List<AKeyPair> keyPairs, State genesisState, int[] peerPorts, IServerEvent event) Launch a local set of peers.static Server
Launches a peer with a default configurtion.static Server
launchPeer
(Map<Keyword, Object> peerConfig) Launches a Peer Server with a supplied configuration.
-
Constructor Details
-
API
public API()
-
-
Method Details
-
launchPeer
Launches a Peer Server with a supplied configuration.
Config keys are:
- :keypair (required, AKeyPair) - AKeyPair instance.
- :port (optional, Integer) - Integer port number to use for incoming connections. Zero causes random allocation (also the default).
- :store (optional, AStore) - AStore instance. Defaults to the configured global store
- :source (optional, String) - URL for Peer to replicate initial State/Belief from.
- :state (optional, State) - Genesis state. Defaults to a fresh genesis state for the Peer if neither :source nor :state is specified
- :restore (optional, Boolean) - Boolean Flag to restore from existing store. Default to true
- :persist (optional, Boolean) - Boolean flag to determine if peer state should be persisted in store at server close. Default true.
- :url (optional, String) - public URL for server. If provided, peer will set its public on-chain address based on this, and the bind-address to 0.0.0.0.
- :auto-manage (optional Boolean) - set to true for peer to auto-manage own account. Defaults to true.
- :bind-address (optional String) - IP address of the ethernet device to bind too. For public peers set too 0.0.0.0. Default to 127.0.0.1.
- Parameters:
peerConfig
- Config map for the new Peer- Returns:
- New Server instance
-
launchPeer
Launches a peer with a default configurtion. Mainly for testing.- Returns:
-
launchLocalPeers
Launch a local set of peers. Intended mainly for testing / development. The Peers will have a unique genesis State, i.e. an independent network- Parameters:
keyPairs
- List of keypairs for peersgenesisState
- genesis state for local network- Returns:
- List of Servers launched
-
launchLocalPeers
public static List<Server> launchLocalPeers(List<AKeyPair> keyPairs, State genesisState, int[] peerPorts, IServerEvent event) Launch a local set of peers. Intended mainly for testing / development. The Peers will have a unique genesis State, i.e. an independent network- Parameters:
keyPairs
- List of keypairs for peersgenesisState
- enesis state for local networkpeerPorts
- Array of ports to use for each peer, if == null then randomly assign port numbersevent
- Server event handler- Returns:
- List of Servers launched
-
isNetworkReady
Returns a true value if the local network is ready and synced with the same consensus state hash.- Parameters:
serverList
- List of local peer servers running on the local network.timeoutMillis
- Number of milliseconds to wait before exiting with a failure.- Returns:
- Return true if all server peers have the same consensus hash, else false is a timeout.
-