本文整理汇总了Java中org.hyperledger.api.BCSAPIException类的典型用法代码示例。如果您正苦于以下问题:Java BCSAPIException类的具体用法?Java BCSAPIException怎么用?Java BCSAPIException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BCSAPIException类属于org.hyperledger.api包,在下文中一共展示了BCSAPIException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTx
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@GET
@Path("tx/{txId}")
public TransactionRepresentation getTx(@PathParam("txId") TID txId) throws BCSAPIException, HyperLedgerException {
APITransaction tx = api.getTransaction(txId);
List<APITransaction> inputTxs = api.getInputTransactions(txId);
List<String> inputAddresses = new ArrayList<>(inputTxs == null ? 0 : inputTxs.size());
List<String> color = new ArrayList<>(inputTxs == null ? 0 : inputTxs.size());
List<Long> quantity = new ArrayList<>(inputTxs == null ? 0 : inputTxs.size());
if (inputTxs != null) {
int i = 0;
for (APITransaction inputTx : inputTxs) {
if (inputTx == null) {
inputAddresses.add("");
color.add("");
quantity.add(-1L);
} else {
TransactionOutput output = inputTx.getOutput(tx.getSource(i).getOutputIndex());
if (output.getOutputAddress() != null) {
inputAddresses.add(output.getOutputAddress().toString());
if (output instanceof ColoredTransactionOutput) {
color.add(((ColoredTransactionOutput) output).getColor().toString());
quantity.add(((ColoredTransactionOutput) output).getQuantity());
} else {
color.add("");
quantity.add(-1L);
}
} else {
inputAddresses.add("");
color.add("");
quantity.add(-1L);
}
}
i++;
}
}
return TransactionRepresentation.create(tx, inputAddresses, color, quantity);
}
示例2: sync
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void sync(BCSAPI api, TransactionListener txListener) throws BCSAPIException {
log.trace("Sync naddr: " + keys.size());
api.scanTransactionsForAddresses(getRelevantAddresses(), txListener);
log.trace("Sync finished naddr: " + keys.size());
}
示例3: sync
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
protected void sync(MasterPublicKey masterPublicKey, BCSAPI api, TransactionListener txListener) throws BCSAPIException {
log.trace("Sync nkeys: {}", nextSequence);
api.scanTransactions(masterPublicKey, lookAhead, t -> {
for (TransactionOutput o : t.getOutputs()) {
Integer thisKey = getKeyIDForAddress(o.getOutputAddress());
if (thisKey != null) {
ensureLookAhead(thisKey);
nextSequence = Math.max(nextSequence, thisKey + 1);
}
}
txListener.process(t);
});
log.trace("Sync finished with nkeys: {}", nextSequence);
}
示例4: run
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void run(T configuration, Environment environment) throws Exception {
final HyperLedgerConfiguration supernode = getSupernodeConfiguration(configuration);
log.info("Creating BCSAPI instance");
managedBCSAPI = supernode.createBCSAPI();
// jackson module for JSON serialization
environment.getObjectMapper().registerModule(new SupernodeModule(() -> {
try {
return getBCSAPI().ping(0) == 0;
} catch (BCSAPIException e) {
return false;
}
}));
environment.lifecycle().manage(managedBCSAPI);
environment.healthChecks().register("supernode", new HealthCheck() {
@Override
protected Result check() throws Exception {
try {
managedBCSAPI.getBCSAPI().ping(new Random().nextLong());
return Result.healthy("Ping succeeded");
} catch (BCSAPIException be) {
return Result.unhealthy(be);
}
}
});
}
示例5: mineOneBlock
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void mineOneBlock() {
try {
bcsapi.mine(minerAddress);
keyChain.sync(bcsapi, minerAccount);
} catch (BCSAPIException e) {
log.error("Mining failed with: {}", e);
}
}
示例6: sendTo
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void sendTo(String address, long amount) {
try {
TransactionFactory factory = new CoinbaseAwareBaseTransactionFactory(minerAccount, blockStore, coinbaseMaturity);
TransactionProposal proposal = factory.propose(UIAddress.fromSatoshiStyle(address).getAddress(), amount);
Transaction tx = proposal.sign(minerAccount);
bcsapi.sendTransaction(tx);
mineOneBlock();
} catch (HyperLedgerException | BCSAPIException e) {
log.error("Failed sending amount {} to address {}. Problem was {}", amount, address, e);
throw new RuntimeException(e);
}
}
示例7: latestBlocks
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@GET
@Path("block/{blockId}")
public BlockRepresentation latestBlocks(@PathParam("blockId") BID blockId) throws BCSAPIException {
return BlockRepresentation.create(api.getBlock(blockId));
}
示例8: getChainHeight
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@GET
@Path("chain/height")
public ChainHeightRepresentation getChainHeight() throws BCSAPIException {
return ChainHeightRepresentation.create(api.getChainHeight());
}
示例9: sync
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void sync(BCSAPI api, TransactionListener txListener) throws BCSAPIException {
receiver.sync(api, txListener);
change.sync(api, txListener);
}
示例10: sync
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void sync(BCSAPI api, TransactionListener txListener) throws BCSAPIException {
log.trace("Sync naddr: " + keys.size());
api.scanTransactionsForAddresses(getRelevantAddresses(), txListener);
log.trace("Sync finished naddr: " + keys.size());
}
示例11: sync
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void sync(BCSAPI api) throws BCSAPIException {
reset();
addressChain.sync(api, this);
}
示例12: sync
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void sync(BCSAPI api, TransactionListener txListener) throws BCSAPIException {
sync(master.getMasterPublic(), api, txListener);
}
示例13: sync
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void sync(BCSAPI api, TransactionListener txListener) throws BCSAPIException {
log.trace("Sync naddr: " + addresses.size());
api.scanTransactionsForAddresses(addresses, txListener);
log.trace("Sync finished naddr: " + addresses.size());
}
示例14: sync
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Override
public void sync(BCSAPI api, TransactionListener txListener) throws BCSAPIException {
sync(master, api, txListener);
}
示例15: test
import org.hyperledger.api.BCSAPIException; //导入依赖的package包/类
@Test
public void test() throws BCSAPIException {
assertEquals("CURRENT-VERSION", new BCSAPIClient(new InMemoryConnectorFactory()).getClientVersion());
}