MCPcopy Index your code
hub / github.com/chain/Core / main

Method main

docs/core/examples/java/BatchOperations.java:9–148  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

7
8class BatchOperations {
9 public static void main(String[] args) throws Exception {
10 Client client = new Client();
11
12 MockHsm.Key key = MockHsm.Key.create(client);
13 HsmSigner.addKey(key, MockHsm.getSignerClient(client));
14
15 // snippet asset-builders
16 List<Asset.Builder> assetBuilders = Arrays.asList(
17 new Asset.Builder()
18 .setAlias("gold")
19 .addRootXpub(key.xpub)
20 .setQuorum(1),
21 new Asset.Builder()
22 .setAlias("silver")
23 .addRootXpub(key.xpub)
24 .setQuorum(1),
25 new Asset.Builder()
26 .setAlias("bronze")
27 .addRootXpub(key.xpub)
28 .setQuorum(0)
29 );
30 // endsnippet
31
32 // snippet asset-create-batch
33 BatchResponse<Asset> assetBatch = Asset.createBatch(client, assetBuilders);
34 // endsnippet
35
36 // snippet asset-create-handle-errors
37 for (int i = 0; i < assetBatch.size(); i++) {
38 if (assetBatch.isError(i)) {
39 APIException error = assetBatch.errorsByIndex().get(i);
40 System.out.println("asset " + i + " error: " + error);
41 } else {
42 Asset asset = assetBatch.successesByIndex().get(i);
43 System.out.println("asset " + i + " created, ID: " + asset.id);
44 }
45 }
46 // endsnippet
47
48 // snippet nondeterministic-errors
49 assetBuilders = Arrays.asList(
50 new Asset.Builder()
51 .setAlias("platinum")
52 .addRootXpub(key.xpub)
53 .setQuorum(1),
54 new Asset.Builder()
55 .setAlias("platinum")
56 .addRootXpub(key.xpub)
57 .setQuorum(1),
58 new Asset.Builder()
59 .setAlias("platinum")
60 .addRootXpub(key.xpub)
61 .setQuorum(1)
62 );
63 // endsnippet
64
65 assetBatch = Asset.createBatch(client, assetBuilders);
66

Callers

nothing calls this directly

Calls 15

addKeyMethod · 0.95
getSignerClientMethod · 0.95
createBatchMethod · 0.95
buildBatchMethod · 0.95
signBatchMethod · 0.95
submitBatchMethod · 0.95
sizeMethod · 0.80
isErrorMethod · 0.80
errorsByIndexMethod · 0.80
successesByIndexMethod · 0.80
addActionMethod · 0.80
successesMethod · 0.80

Tested by

no test coverage detected