private Binder getContract(Binder params, Session session) throws IOException { checkNode(session, true); Binder res = new Binder(); if (!node.getConfig().isPermanetMode()) return res; HashId origin = (HashId) params.get("origin"); int limit = params.getInt("limit", 100); if (limit > node.getConfig().getQueryContractsLimit()) limit = node.getConfig().getQueryContractsLimit(); if (limit < 1) limit = 1; Object keeping = node.getLedger().getKeepingByOrigin(origin, limit); if (keeping == null) return res; if (keeping instanceof byte[]) res.put("packedContract", keeping); else if (keeping instanceof List) res.put("contractIds", keeping); return res; }
data = node.getLedger().getContractInStorage(id); if ((data == null) && node.getConfig().isPermanetMode()) data = node.getLedger().getKeepingItem(id);
private Binder getBody(Binder params, Session session) throws IOException { checkNode(session, true); Binder res = new Binder(); if (!node.getConfig().isPermanetMode()) return res; HashId itemId = (HashId) params.get("itemId"); byte[] body = node.getLedger().getKeepingItem(itemId); if (body != null) { res.put("packedContract", body); return res; } node.resync(itemId); ItemResult itemResult = node.checkItem(itemId); if (itemResult == ItemResult.UNDEFINED) return res; Approvable item = node.getKeepingItemFromNetwork(itemId); if (item == null) return res; if ((item instanceof Contract) && (item.getId().equals(itemId)) && (HashId.of(((Contract) item).getLastSealedBinary()).equals(itemId))) { StateRecord record = node.getLedger().getRecord(itemId); node.getLedger().putKeepingItem(record, item); body = ((Contract) item).getPackedTransaction(); res.put("packedContract", body); } return res; }
for (Long envId : envs) { NImmutableEnvironment environment = networkNode.getLedger().getEnvironment(envId); double days = (double) 100 * networkNode.getConfig().getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue() * 1024 / simpleContract.getPackedTransaction().length; double hours = days * 24; long seconds = (long) (days * 24 * 3600); for (Long envId : envs) { NImmutableEnvironment environment = node.getLedger().getEnvironment(envId); double days = (double) 100 * node.getConfig().getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue() * 1024 / simpleContract.getPackedTransaction().length; double hours = days * 24; long seconds = (long) (days * 24 * 3600);