Exemplo n.º 1
0
 @Override
 public void scanTransactionsForAddresses(Set<Address> addresses, TransactionListener listener)
     throws BCSAPIException {
   List<Script> al = new ArrayList<>(addresses.size());
   for (Address a : addresses) {
     try {
       al.add(a.getAddressScript());
     } catch (HyperLedgerException e) {
     }
   }
   scanRequest(al, listener, "matchRequest");
 }
Exemplo n.º 2
0
  @Override
  public APIHeader mine(Address address) throws BCSAPIException {
    try (ConnectorSession session = connection.createSession()) {
      log.trace("mine to " + address);

      ConnectorProducer producer = session.createProducer(session.createTopic("mine"));

      ConnectorMessage m = session.createMessage();
      BCSAPIMessage.Script.Builder builder =
          BCSAPIMessage.Script.newBuilder()
              .setScript(ByteString.copyFrom(address.getAddressScript().toByteArray()));
      m.setPayload(builder.build().toByteArray());
      byte[] reply = synchronousRequest(session, producer, m);
      if (reply != null) {
        return APIHeader.fromProtobuf(BCSAPIMessage.BLK.parseFrom(reply));
      }
    } catch (ConnectorException | InvalidProtocolBufferException | HyperLedgerException e) {
      throw new BCSAPIException(e);
    }
    return null;
  }