private Binder startApproval(final Binder params, Session session) throws IOException, Quantiser.QuantiserException { if (config == null || config.limitFreeRegistrations()) if(config == null || ( !config.getKeysWhiteList().contains(session.getPublicKey()) && !config.getAddressesWhiteList().stream().anyMatch(addr -> addr.isMatchingKey(session.getPublicKey())))) { System.out.println("startApproval ERROR: session key shoild be in the white list"); return Binder.of( "itemResult", itemResultOfError(Errors.BAD_CLIENT_KEY,"startApproval", "command needs client key from whitelist")); } int n = asyncStarts.incrementAndGet(); AtomicInteger k = new AtomicInteger(); params.getListOrThrow("packedItems").forEach((item) -> es.execute(() -> { try { checkNode(session); System.out.println("Request to start registration #"+n+":"+k.incrementAndGet()); node.registerItem(Contract.fromPackedTransaction(((Bytes)item).toArray())); } catch (Exception e) { e.printStackTrace(); } }) ); //TODO: return ItemResult return new Binder(); }
if (config.limitFreeRegistrations()) if(!(tmpAddress.isMatchingKey(session.getPublicKey()) || config.getNetworkAdminKeyAddress().isMatchingKey(session.getPublicKey()) ||
checkNode(session); if (config.limitFreeRegistrations() && (!( config.getNetworkAdminKeyAddress().isMatchingKey(session.getPublicKey()) ||
private Binder resyncItem(Binder params, Session session) throws CommandFailedException { checkNode(session, true); KeyAddress tmpAddress = null; try { tmpAddress = new KeyAddress("JKEgDs9CoCCymD9TgmjG8UBLxuJwT5GZ3PaZyG6o2DQVGRQPjXHCG8JouC8eZw5Nd1w9krCS"); } catch (KeyAddress.IllegalAddressException e) { e.printStackTrace(); } if (config.limitFreeRegistrations()) if(!( tmpAddress.isMatchingKey(session.getPublicKey()) || config.getNetworkAdminKeyAddress().isMatchingKey(session.getPublicKey()) || config.getKeysWhiteList().contains(session.getPublicKey()) || config.getAddressesWhiteList().stream().anyMatch(addr -> addr.isMatchingKey(session.getPublicKey())) )) { System.out.println("approve ERROR: command needs client key from whitelist"); return Binder.of( "itemResult", itemResultOfError(Errors.BAD_CLIENT_KEY,"resyncItem", "command needs client key from whitelist")); } try { Binder result = Binder.of("itemResult", node.checkItem((HashId) params.get("itemId"))); node.resync((HashId) params.get("itemId")); return result; } catch (Exception e) { System.out.println("getState ERROR: " + e.getMessage()); return Binder.of( "itemResult", itemResultOfError(Errors.COMMAND_FAILED,"resyncItem", e.getMessage())); } }