congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
Client.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.icodici.universa.node2.network.Client
constructor

Best Java code snippets using com.icodici.universa.node2.network.Client.<init> (Showing top 20 results out of 315)

origin: UniversaBlockchain/universa

public Client getClient(int i) throws IOException {
  Client c = clients.get(i);
  if (c == null) {
    NodeRecord r = nodes.get(i);
    c = new Client(r.url, clientPrivateKey, r.key, null);
    clients.set(i, c);
  }
  return c;
}
origin: UniversaBlockchain/universa

@Override
public ItemResult getItemState(NodeInfo nodeInfo, HashId id) throws IOException {
  Client client;
  synchronized (cachedClients) {
    client = cachedClients.get(nodeInfo);
    if( client == null ) {
      client = new Client(myKey, nodeInfo, null);
      cachedClients.put(nodeInfo, client);
    }
  }
  return client.getState(id);
}
origin: UniversaBlockchain/universa

private Client createWhiteClient() {
  try {
    int nodeNumber = ThreadLocalRandom.current().nextInt(1, 11);
    String nodeUrl = "http://node-" + nodeNumber + "-pro.universa.io:8080";
    PrivateKey clientKey = TestKeys.privateKey(nodeNumber-1);
    return new Client(nodeUrl, clientKey, null, false);
  } catch (Exception e) {
    System.out.println("createWhiteClient exception: " + e.toString());
    return null;
  }
}
origin: UniversaBlockchain/universa

public ClientNetwork(String nodeUrl, PrivateKey privateKey, BasicHttpClientSession session) throws IOException {
  client = new Client(nodeUrl, privateKey, session);
  if (client == null)
    throw new IOException("failed to connect to to the universa network");
  reporter.verbose("Read Universa network configuration: " + client.size() + " nodes");
  reporter.message("Network version: " + client.getVersion());
}
origin: UniversaBlockchain/universa

  private static void createNodeClient() throws Exception {
//        List<Main> mm = new ArrayList<>();
//        for (int i = 0; i < 4; i++)
//            mm.add(createMain("node" + (i + 1), false));
//
//        Thread.sleep(2000);

    clients = new ArrayList<>();
    for (int i = 0; i < 10; ++i) {
      int n = i+1;
      String nodeUrl = "http://node-"+n+"-pro.universa.io:8080";
      PrivateKey clientKey = TestKeys.privateKey(i);
      Client client = new Client(nodeUrl, clientKey, null, false);
      clients.add(client);
    }

    nodeClient = clients.get(0);
    Thread.sleep(100);
  }

origin: UniversaBlockchain/universa

public ClientNetwork(String nodeUrl, BasicHttpClientSession session, boolean delayedStart) throws IOException {
  client = new Client(nodeUrl, CLIMain.getPrivateKey(), session, delayedStart);
  if (client == null)
    throw new IOException("failed to connect to to the universa network");
  reporter.verbose("Read Universa network configuration: " + client.size() + " nodes");
  reporter.message("Network version: " + client.getVersion());
}
origin: UniversaBlockchain/universa

private TestSpace prepareTestSpace(PrivateKey key) throws Exception {
  TestSpace testSpace = new TestSpace();
  testSpace.nodes = new ArrayList<>();
  for (int i = 0; i < 4; i++)
    testSpace.nodes.add(createMain("node" + (i + 1), false));
  testSpace.node = testSpace.nodes.get(0);
  assertEquals("http://localhost:8080", testSpace.node.myInfo.internalUrlString());
  assertEquals("http://localhost:8080", testSpace.node.myInfo.publicUrlString());
  testSpace.myKey = key;
  testSpace.client = new Client(testSpace.myKey, testSpace.node.myInfo, null);
  testSpace.clients = new ArrayList();
  for (int i = 0; i < 4; i++)
    testSpace.clients.add(new Client(testSpace.myKey, testSpace.nodes.get(i).myInfo, null));
  return testSpace;
}
origin: UniversaBlockchain/universa

public ClientNetwork(BasicHttpClientSession session, boolean delayedStart) throws IOException {
  for (int i = 1; i < 10; i++) {
    try {
      client = new Client("http://node-" +
          Do.randomIntInRange(1, 10) +
          "-com.universa.io:8080", CLIMain.getPrivateKey(), session, delayedStart);
      break;
    } catch (IOException e) {
      reporter.warning("failed to read network from node " + i);
    }
  }
  if (client == null)
    throw new IOException("failed to connect to to the universa network");
  reporter.verbose("Read Universa network configuration: " + client.size() + " nodes");
  reporter.message("Network version: " + client.getVersion());
}
origin: UniversaBlockchain/universa

private TestSpace prepareTestSpace(PrivateKey key) throws Exception {
  TestSpace testSpace = new TestSpace();
  testSpace.nodes = new ArrayList<>();
  for (int i = 0; i < 4; i++)
    testSpace.nodes.add(createMain("node" + (i + 1), "", false));
  testSpace.node = testSpace.nodes.get(0);
  assertEquals("http://localhost:8080", testSpace.node.myInfo.internalUrlString());
  assertEquals("http://localhost:8080", testSpace.node.myInfo.publicUrlString());
  testSpace.myKey = key;
  testSpace.client = new Client(testSpace.myKey, testSpace.node.myInfo, null);
  testSpace.clients = new ArrayList();
  for (int i = 0; i < 4; i++)
    testSpace.clients.add(new Client(testSpace.myKey, testSpace.nodes.get(i).myInfo, null));
  for (Main m : testSpace.nodes) {
    while (m.node.isSanitating())
      Thread.sleep(100);
  }
  return testSpace;
}
origin: UniversaBlockchain/universa

@Test
public void freeRegistrationsAllowedFromCoreVersion() throws Exception {
  List<Main> mm = new ArrayList<>();
  for (int i = 0; i < 4; i++)
    mm.add(createMain("node" + (i + 1), false));
  Main main = mm.get(0);
  Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.seal();
  ItemState expectedState = ItemState.UNDEFINED;
  if (Core.VERSION.contains("private"))
    expectedState = ItemState.APPROVED;
  System.out.println("Core.VERSION: " + Core.VERSION);
  System.out.println("expectedState: " + expectedState);
  ItemResult itemResult = client.register(contract.getPackedTransaction(), 5000);
  System.out.println("itemResult: " + itemResult);
  assertEquals(expectedState, itemResult.state);
  mm.forEach(x -> x.shutdown());
}
origin: UniversaBlockchain/universa

@Test
public void freeRegistrationsAllowedFromConfigOrVersion() throws Exception {
  List<Main> mm = new ArrayList<>();
  for (int i = 0; i < 4; i++)
    mm.add(createMain("node" + (i + 1), false));
  Main main = mm.get(0);
  main.config.setIsFreeRegistrationsAllowedFromYaml(true);
  Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.seal();
  ItemState expectedState = ItemState.APPROVED;
  System.out.println("expectedState: " + expectedState);
  ItemResult itemResult = client.register(contract.getPackedTransaction(), 5000);
  System.out.println("itemResult: " + itemResult);
  assertEquals(expectedState, itemResult.state);
  main.config.setIsFreeRegistrationsAllowedFromYaml(false);
  contract = new Contract(TestKeys.privateKey(0));
  contract.seal();
  expectedState = ItemState.UNDEFINED;
  if (Core.VERSION.contains("private"))
    expectedState = ItemState.APPROVED;
  System.out.println("Core.VERSION: " + Core.VERSION);
  System.out.println("expectedState: " + expectedState);
  itemResult = client.register(contract.getPackedTransaction(), 5000);
  System.out.println("itemResult: " + itemResult);
  assertEquals(expectedState, itemResult.state);
  mm.forEach(x -> x.shutdown());
}
origin: UniversaBlockchain/universa

@Test
public void paymentTest1() throws Exception {
  List<Main> mm = new ArrayList<>();
  for (int i = 0; i < 4; i++)
    mm.add(createMain("node" + (i + 1), false));
  Main main = mm.get(0);
  main.config.setIsFreeRegistrationsAllowedFromYaml(true);
  Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
  Contract simpleContract = new Contract(TestKeys.privateKey(1));
  simpleContract.seal();
  Contract stepaU = InnerContractsService.createFreshU(100000000, new HashSet<>(Arrays.asList(TestKeys.publicKey(1))));
  ItemResult itemResult = client.register(stepaU.getPackedTransaction(), 5000);
  System.out.println("stepaU itemResult: " + itemResult);
  assertEquals(ItemState.APPROVED, itemResult.state);
  main.config.setIsFreeRegistrationsAllowedFromYaml(false);
  Parcel parcel = ContractsService.createParcel(simpleContract, stepaU, 1, new HashSet<>(Arrays.asList(TestKeys.privateKey(1))), false);
  client.registerParcelWithState(parcel.pack(), 5000);
  assertEquals(ItemState.APPROVED, client.getState(simpleContract.getId()).state);
  mm.forEach(x -> x.shutdown());
}
protected static final String ROOT_PATH = "./src/test_contracts/";
origin: UniversaBlockchain/universa

@Test
public void checkWhiteListKey() throws Exception {
  List<Main> mm = new ArrayList<>();
  for (int i = 0; i < 3; i++) {
    mm.add(createMain("node" + (i + 1), false));
  }
  Main main = mm.get(0);
  PrivateKey myKey = TestKeys.privateKey(3);
  Client client = null;
  try {
    client = new Client(myKey, main.myInfo, null);
  } catch (Exception e) {
    System.out.println("prepareClient exception: " + e.toString());
  }
  Contract testContract = new Contract(myKey);
  for (int i = 0; i < 10; i++) {
    Contract nc = new Contract(myKey);
    nc.seal();
    testContract.addNewItems(nc);
  }
  testContract.seal();
  assertTrue(testContract.isOk());
  Parcel parcel = createParcelWithFreshU(client, testContract,Do.listOf(myKey));
  ItemResult itemResult = client.registerParcelWithState(parcel.pack(), 15000);
  System.out.println(">> state: " + itemResult);
  assertEquals (ItemState.APPROVED, itemResult.state);
  mm.forEach(x -> x.shutdown());
}
origin: UniversaBlockchain/universa

@Test
public void testRevocationContractsApi() throws Exception {
  List<Main> mm = new ArrayList<>();
  for (int i = 0; i < 4; i++)
    mm.add(createMain("node" + (i + 1), false));
  Main main = mm.get(0);
  main.config.setIsFreeRegistrationsAllowedFromYaml(true);
  Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
  Set<PrivateKey> issuerPrivateKeys = new HashSet<>(Arrays.asList(TestKeys.privateKey(1)));
  Set<PublicKey> ownerPublicKeys = new HashSet<>(Arrays.asList(TestKeys.publicKey(2)));
  Contract sourceContract = ContractsService.createShareContract(issuerPrivateKeys, ownerPublicKeys, new BigDecimal("100"));
  sourceContract.check();
  sourceContract.traceErrors();
  ItemResult itemResult = client.register(sourceContract.getPackedTransaction(), 5000);
  System.out.println("sourceContract : " + itemResult);
  assertEquals(ItemState.APPROVED, client.getState(sourceContract.getId()).state);
  Contract revokeContract = ContractsService.createRevocation(sourceContract, TestKeys.privateKey(1));
  revokeContract.check();
  revokeContract.traceErrors();
  itemResult = client.register(revokeContract.getPackedTransaction(), 5000);
  System.out.println("revokeContract : " + itemResult);
  assertEquals(ItemState.APPROVED, client.getState(revokeContract.getId()).state);
  assertEquals(ItemState.REVOKED, client.getState(sourceContract.getId()).state);
  mm.forEach(x -> x.shutdown());
 }
origin: UniversaBlockchain/universa

Main main = mm.get(0);
main.config.setIsFreeRegistrationsAllowedFromYaml(true);
Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
origin: UniversaBlockchain/universa

main.config.setIsFreeRegistrationsAllowedFromYaml(true);
main.config.getKeysWhiteList().add(TestKeys.publicKey(20));
Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
origin: UniversaBlockchain/universa

Main main = mm.get(0);
main.config.setIsFreeRegistrationsAllowedFromYaml(true);
Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
origin: UniversaBlockchain/universa

Main main = mm.get(0);
main.config.setIsFreeRegistrationsAllowedFromYaml(true);
Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
origin: UniversaBlockchain/universa

Main main = mm.get(0);
main.config.setIsFreeRegistrationsAllowedFromYaml(true);
Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
origin: UniversaBlockchain/universa

Main main = mm.get(0);
main.config.setIsFreeRegistrationsAllowedFromYaml(true);
Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
com.icodici.universa.node2.networkClient<init>

Javadoc

Start new client protocol session. It doesn't load network configuration. Only creates client protocol session with given node

Popular methods of Client

  • getState
  • getClient
  • getNodes
    Get list of nodes in
  • ping
  • register
    Register contract on the network without payment. May require special client key / network configura
  • command
    Execude custom command on the node
  • getNodeNumber
    Get number of node cliet connection is established with
  • getVersion
    Get network version
  • registerParcelWithState
    Register contract on the network with parcel (includes payment) and wait for some of the final ItemS
  • getParcelProcessingState
    Get processing state of given parcel
  • getSession
    Get session of http client connected to node with given number
  • getStats
    Get extended statistics of the node including by-day payments in "U". Accessible to node owners (wit
  • getSession,
  • getStats,
  • queryContract,
  • resyncItem,
  • setVerboseLevel,
  • size,
  • followerGetRate,
  • getBody,
  • getContract

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (Timer)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • Permission (java.security)
    Legacy security code; do not use.
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now