Tabnine Logo
Client
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: UniversaBlockchain/universa

Client client = new Client(nodeUrl,TestKeys.privateKey(0),null);
System.out.println("Network version: " + client.getVersion());
final int NODES_COUNT = client.getNodes().size();
  clients.put(i,client.getClient(i));
  clients.get(i).ping();
      long from = System.currentTimeMillis();
      try {
        clients.get(fI).command("startApproval", "packedItems", bytes.get(Pair.of(k,fI)));
      } catch (IOException e) {
        e.printStackTrace();
            ItemResult rr;
            Contract c = contracts.get(Pair.of(k,fI)).get(j);
            rr = clients.get(fI).getState(c.getId());
            if (!rr.state.isApproved()) {
              found = true;
origin: UniversaBlockchain/universa

/**
 * Register contract on the network without payment. May require special client key / network configuration
 * @param packed {@link com.icodici.universa.contract.TransactionPack} binary
 * @return result of registration
 * @throws ClientError
 */
public ItemResult register(byte[] packed) throws ClientError {
  return register(packed, 0);
}
origin: UniversaBlockchain/universa

  @Test
  public void nodeVersion() throws Exception {
    System.out.println("nodeClient.getNodeNumber(): " + nodeClient.getNodeNumber());
    System.out.println("nodeClient.getSession(): " + nodeClient.getSession());
    System.out.println("nodeClient.ping(): " + nodeClient.ping());
    System.out.println("nodeClient.getState(random): " + nodeClient.getState(HashId.createRandom()));
    System.out.println("nodeClient.getNodes().size(): " + nodeClient.getNodes().size());
    System.out.println("nodeClient.getVersion(): " + nodeClient.getVersion());
    System.out.println("nodeClient.getPositiveConsensus(): " + nodeClient.getPositiveConsensus());
    System.out.println("nodeClient.getUrl(): " + nodeClient.getUrl());
//        PublicKey publicKey = new PublicKey(Bytes.fromHex("1E 08 1C 01 00 01 C4 00 01 C5 24 96 7D 75 B6 D3 01 AC 46 7F 64 85 56 43 B6 F7 02 B5 4A 8F FE C7 0D DE 85 4F 53 7A F4 D7 9D 85 BB AD A9 7F 1F 4C 8D CD 5C 99 09 D1 61 29 1E 67 35 80 E7 44 58 41 35 37 16 55 C2 E6 22 0D EF 0F 8B 9B A4 C6 3D 0C 56 7B EB 98 18 C8 0A 2C 26 C0 9B 23 17 3D 6B A9 BF 37 81 E5 21 0C B7 29 50 E6 69 75 DA 2C 05 42 46 A6 A8 E8 85 13 62 96 31 8C FF 50 68 56 F3 BF C4 2C F7 24 9A 9A 1A 9D 95 1A F0 E1 82 00 25 1F 14 60 0B 01 95 74 1B EA D0 FF CC 62 5B 78 64 18 79 8E 14 FD 24 7A 36 5A 09 91 8F 3B F5 C6 55 AC BE DA AD 15 D9 CC 3A 08 76 AB F8 3F 45 F4 5A 26 5D 80 38 6C 02 27 95 8D F3 38 B1 DD 1B C7 5D 51 3C E1 1D 05 8E 2A 6C E8 17 D7 88 5B AE D4 F6 B7 7D A8 84 74 E1 4F 65 B3 DC 06 2D 07 21 AA 51 BF 93 11 C7 7D 1E 09 B3 CE A6 C1 83 60 50 A5 B8 F5 F4 11 A6 98 A0 F9 2B 2B 8D").getData());
//        PublicKey publicKey = new PublicKey(Bytes.fromBase64("HggcAQABxAABxSSWfXW20wGsRn9khVZDtvcCtUqP/scN3oVPU3r0152Fu62pfx9Mjc1cmQnRYSkeZzWA50RYQTU3FlXC5iIN7w+Lm6TGPQxWe+uYGMgKLCbAmyMXPWupvzeB5SEMtylQ5ml12iwFQkamqOiFE2KWMYz/UGhW87/ELPckmpoanZUa8OGCACUfFGALAZV0G+rQ/8xiW3hkGHmOFP0kejZaCZGPO/XGVay+2q0V2cw6CHar+D9F9FomXYA4bAInlY3zOLHdG8ddUTzhHQWOKmzoF9eIW67U9rd9qIR04U9ls9wGLQchqlG/kxHHfR4Js86mwYNgUKW49fQRppig+SsrjQ==").getData());
//        System.out.println("transactionUnitsIssuerKey address: " + publicKey.getShortAddress());
//        System.out.println("transactionUnitsIssuerKey base64: " + publicKey.packToBase64String());
  }

origin: UniversaBlockchain/universa

public boolean ping(int i) {
  try {
    return getClient(i).ping();
  } catch (Exception e) {
  }
  return false;
}
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

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

@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

  client = new Client(myKey, main.myInfo, null);
} catch (Exception e) {
  System.out.println("prepareClient exception: " + e.toString());
assertTrue(testContract.isOk());
Parcel parcel = createParcelWithFreshU(client, testContract,Do.listOf(myKey));
client.registerParcelWithState(parcel.pack(), 5000);
System.out.println(">> before shutdown state: " + client.getState(parcel.getPayloadContract().getId()));
System.out.println(">> before shutdown state: " + client.getState(parcel.getPayloadContract().getNew().get(0).getId()));
mm.add(main);
try {
  client = new Client(myKey, main.myInfo, null);
} catch (Exception e) {
  System.out.println("prepareClient exception: " + e.toString());
ItemResult itemResult = client.getState(parcel.getPayloadContract().getId());
ItemResult itemResult2 = client.getState(parcel.getPayloadContract().getNew().get(0).getId());
System.out.println(">> after shutdown state: " + itemResult + " and new " + itemResult2);
  itemResult = client.getState(parcel.getPayloadContract().getId());
  System.out.println(">> wait result: " + itemResult);
itemResult2 = client.getState(parcel.getPayloadContract().getNew().get(0).getId());
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

Client client = null;
try {
  client = new Client(myKey, main.myInfo, null);
} catch (Exception e) {
  System.out.println("prepareClient exception: " + e.toString());
stepaU.traceErrors();
PrivateKey clientPrivateKey = client.getSession().getPrivateKey();
client.getSession().setPrivateKey(newPrivateKey);
client.restart();
ItemResult itemResult = client.register(stepaU.getPackedTransaction(), 5000);
client.getSession().setPrivateKey(clientPrivateKey);
client.restart();
keySet.addAll(keys);
Parcel parcel = ContractsService.createParcel(testContract, stepaU, 150, keySet);
client.registerParcelWithState(parcel.pack(), 15000);
itemResult = client.getState(parcel.getPayloadContract().getId());
System.out.println(">> state: " + itemResult);
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 registerSimpleContractWhite() throws Exception {
  Contract whiteContract = new Contract(TestKeys.privateKey(0));
  whiteContract.seal();
  System.out.println("whiteClient.register(whiteContract)...");
  ItemResult itemResult = whiteClient.register(whiteContract.getPackedTransaction(), 5000);
  System.out.println("whiteClient.register(whiteContract)... done! itemResult: " + itemResult.state);
  itemResult = whiteClient.getState(whiteContract.getId());
  System.out.println("whiteClient.getState(whiteContract): " + itemResult.state);
  assertEquals(ItemState.APPROVED, itemResult.state);
}
origin: UniversaBlockchain/universa

ItemResult itemResult = testSpace.client.register(contractServer.getPackedTransaction(), 5000);
assertEquals(ItemState.APPROVED, itemResult.state);
slotContract.putTrackingContract(contractServer);
Contract stepaU = InnerContractsService.createFreshU(100000000, new HashSet<>(Arrays.asList(TestKeys.publicKey(0))));
itemResult = testSpace.client.register(stepaU.getPackedTransaction(), 5000);
System.out.println("stepaU : " + itemResult);
assertEquals(ItemState.APPROVED, itemResult.state);
Parcel parcel = ContractsService.createPayingParcel(slotContract.getTransactionPack(), stepaU, 1, 100, new HashSet<>(Arrays.asList(TestKeys.privateKey(0))), false);
testSpace.client.registerParcelWithState(parcel.pack(), 5000);
itemResult = testSpace.client.getState(slotContract.getId());
System.out.println("slot : " + itemResult);
assertEquals(ItemState.APPROVED, itemResult.state);
    Binder slotInfo = testSpace.client.querySlotInfo(slotId);
    return testSpace.client.queryContract(slotId, originId, null);
  } catch (ClientError e) {
    e.printStackTrace();
JSApiHttpServer httpServer = new JSApiHttpServer(routes, new JSApiExecOptions(), hashId -> {
      try {
        return testSpace.client.getState(hashId).state == ItemState.APPROVED;
      } catch (ClientError e) {
        e.printStackTrace();
contractServer2.seal();
contractServer2 = Contract.fromPackedTransaction(contractServer2.getPackedTransaction());
ItemResult itemResult2 = testSpace.client.register(contractServer2.getPackedTransaction(), 5000);
assertEquals(ItemState.APPROVED, itemResult2.state);
origin: UniversaBlockchain/universa

@Ignore
@Test
public void registerSimpleContractWithPayment() throws Exception {
  Contract contractToRegister = new Contract(TestKeys.privateKey(10));
  contractToRegister.seal();
  ItemResult itemResult = normalClient.register(contractToRegister.getPackedTransaction(), 5000);
  System.out.println("register... done! itemResult: " + itemResult.state);
  assertEquals(ItemState.UNDEFINED, itemResult.state);
  Parcel parcel = ContractsService.createParcel(contractToRegister, paymentContract, 1, Stream.of(paymentContractPrivKey).collect(Collectors.toSet()), true);
  normalClient.registerParcelWithState(parcel.pack(), 5000);
  itemResult = normalClient.getState(parcel.getPaymentContract().getId());
  if (itemResult.state == ItemState.APPROVED)
    paymentContract = parcel.getPaymentContract();
  System.out.println("registerParcel... done!");
  System.out.println("parcel.paymentContract.itemResult: " + itemResult);
  assertEquals(ItemState.APPROVED, itemResult.state);
  itemResult = normalClient.getState(contractToRegister.getId());
  System.out.println("contractToRegister.itemResult: " + itemResult);
  assertEquals(ItemState.APPROVED, itemResult.state);
}
origin: UniversaBlockchain/universa

Main main = mm.get(0);
main.config.setIsFreeRegistrationsAllowedFromYaml(true);
Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
Decimal kilobytesAndDaysPerU = client.storageGetRate();
System.out.println("storageGetRate: " + kilobytesAndDaysPerU);
assertEquals(new Decimal(main.config.getServiceRate("SLOT1").toString()), kilobytesAndDaysPerU);
ItemResult itemResult = client.register(simpleContract.getPackedTransaction(), 5000);
assertEquals(ItemState.APPROVED, itemResult.state);
itemResult = client.register(stepaU.getPackedTransaction(), 5000);
System.out.println("stepaU : " + itemResult);
assertEquals(ItemState.APPROVED, itemResult.state);
Binder slotInfo = client.querySlotInfo(slotContract.getId());
System.out.println("slot info is null: " + (slotInfo == null));
assertNull(slotInfo);
byte[] simpleContractBytes = client.queryContract(slotContract.getId(), null, simpleContract.getId());
System.out.println("simpleContractBytes (by contractId): " + simpleContractBytes);
assertEquals(false, Arrays.equals(simpleContract.getPackedTransaction(), simpleContractBytes));
simpleContractBytes = client.queryContract(slotContract.getId(), simpleContract.getOrigin(), null);
System.out.println("simpleContractBytes (by originId): " + simpleContractBytes);
assertEquals(false, Arrays.equals(simpleContract.getPackedTransaction(), simpleContractBytes));
client.registerParcelWithState(parcel.pack(), 5000);
itemResult = client.getState(slotContract.getId());
origin: UniversaBlockchain/universa

Client client = null;
try {
  client = new Client(myKey, main.myInfo, null);
} catch (Exception e) {
  System.out.println("prepareClient exception: " + e.toString());
payment.traceErrors();
client.register(payment.getPackedTransaction());
Thread.currentThread().sleep(5000);
  System.out.println(">> storage rate: " + client.storageGetRate());
  client.storageGetRate();            // limited request
} catch (Exception e) {
  System.out.println("Client exception: " + e.toString());
ItemResult itemResult = client.register(unlimitContract.getPackedTransaction());
Thread.currentThread().sleep(5000);
itemResult = client.getState(unlimitContract.getId());
System.out.println(">> state: " + itemResult);
  System.out.println(">> storage rate: " + client.storageGetRate());
  System.out.println(">> uns rate: " + client.unsRate());
  client.getStats(90);
origin: UniversaBlockchain/universa

Client clients = new Client("http://node-" + 1 + "-com.universa.io:8080", key, null, false);
System.out.println(clients.getVersion());
  try {
    Client c = clients.getClient(i);
        ItemResult ir = c.getState(id);
        System.out.println("this " + id + " node: " + finalI +" " + ir.state + " - " + ir.createdAt + " " + ir.expiresAt);
        if(!results.get(id).containsKey(ir.state)) {
        ItemResult ir = c.getState(id);
        System.out.println("revoking " + id + " node: " + finalI +" " + ir.state + " - " + ir.createdAt + " " + ir.expiresAt);
        if(!resultsRevoking.get(id).containsKey(ir.state)) {
        ItemResult ir = c.getState(id);
        System.out.println("new " + id + " node: " + finalI +" " + ir.state + " - " + ir.createdAt + " " + ir.expiresAt);
        if(!resultsNew.get(id).containsKey(ir.state)) {
origin: UniversaBlockchain/universa

final int checkConsensus = getNodes().size() / 3;
return protect(() -> {
  final Map<ItemState, List<ItemResult>> states = new HashMap<>();
  for (int i = 0; i < nodes.size(); i++) {
          Client c = getClient(nn);
          ItemResult r = c.command("getState", "itemId", itemId).getOrThrow("itemResult");
          r.meta.put("url", c.getNodeNumber());
              reporter.warning("errors from " + c.getNodeNumber() + ": " + r.errors);
            break;
origin: UniversaBlockchain/universa

    new BigDecimal("9000")
);
ItemResult ir1 = testSpace.client.register(contractMoney.getPackedTransaction(), 5000);
assertEquals(ItemState.APPROVED, ir1.state);
testSpace.clients.get(testSpace.clients.size()-1).resyncItem(contractMoney.getId());
long millisToWait = 60000;
long waitPeriod = 2000;
  Thread.sleep(waitPeriod);
  millisToWait -= waitPeriod;
  ir = testSpace.clients.get(testSpace.clients.size()-1).getState(contractMoney.getId());
  if (ir.state == ItemState.APPROVED)
    break;
origin: UniversaBlockchain/universa

Decimal namesAndDaysPerU = testSpace.client.unsRate();
System.out.println("unsRate: " + namesAndDaysPerU);
assertEquals(testSpace.node.config.getServiceRate("UNS1").doubleValue(), namesAndDaysPerU.doubleValue(), 0.000001);
ItemResult itemResult = testSpace.client.register(simpleContract.getPackedTransaction(), 5000);
assertEquals(ItemState.APPROVED, itemResult.state);
Binder nameInfo = testSpace.client.queryNameRecord(simpleContract.getId());
String name = nameInfo.getString("name", null);
System.out.println("name info is null: " + (name == null));
assertNull(name);
byte[] unsContractBytes = testSpace.client.queryNameContract(unsTestName);
System.out.println("unsContractBytes: " + unsContractBytes);
assertEquals(false, Arrays.equals(unsContract.getPackedTransaction(), unsContractBytes));
testSpace.client.registerParcelWithState(payingParcel.pack(), 8000);
itemResult = testSpace.client.getState(unsContract.getId());
System.out.println("Uns : " + itemResult);
assertEquals(ItemState.APPROVED, itemResult.state);
nameInfo = testSpace.client.queryNameRecord(simpleContract.getId());
assertNotNull(nameInfo);
System.out.println("name info size: " + nameInfo.size());
unsContractBytes = testSpace.client.queryNameContract(unsTestName);
System.out.println("unsContractBytes: " + unsContractBytes);
assertEquals(true, Arrays.equals(unsContract.getPackedTransaction(), unsContractBytes));
com.icodici.universa.node2.networkClient

Most used methods

  • getState
  • <init>
    Create new client protocol session. It loads network configuration and creates client protocol sessi
  • 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
  • getParcelProcessingState,
  • getSession,
  • getStats,
  • queryContract,
  • resyncItem,
  • setVerboseLevel,
  • size,
  • followerGetRate,
  • getBody,
  • getContract

Popular in Java

  • Updating database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • onCreateOptionsMenu (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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