Package convex.peer
Class API
java.lang.Object
convex.peer.API
Class providing a simple API to a peer Server.
Suitable for library usage, e.g. if a usr 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 TypeMethodDescriptionlaunchLocalPeers(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
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 instance.
- :port (optional) - Integer port number to use for incoming connections. Defaults to random allocation.
- :store (optional) - AStore instance. Defaults to the configured global store
- :source (optional) - URL for Peer to replicate initial State/Belief from.
- :state (optional) - Genesis state. Defaults to a fresh genesis state for the Peer if neither :source nor :state is specified
- :restore (optional) - Boolean Flag to restore from existing store. Default to true
- :persist (optional) - Boolean flag to determine if peer state should be persisted in store at server close. Default true.
- Parameters:
peerConfig
- Config map for the new Peerevent
- Optional event object that implements the IServerEvent interface- Returns:
- New Server instance
-
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
- GEnesis 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
-