Package convex.peer

Class API

java.lang.Object
convex.peer.API

public class API extends Object
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 Details

    • API

      public API()
  • Method Details

    • launchPeer

      public static Server launchPeer(Map<Keyword,​Object> peerConfig)

      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 Peer
      event - Optional event object that implements the IServerEvent interface
      Returns:
      New Server instance
    • launchLocalPeers

      public static List<Server> launchLocalPeers(List<AKeyPair> keyPairs, State genesisState)
      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 peers
      genesisState - 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 peers
      genesisState - GEnesis state for local network
      peerPorts - Array of ports to use for each peer, if == null then randomly assign port numbers
      event - Server event handler
      Returns:
      List of Servers launched