|
4 | 4 | import com.hedera.hashgraph.sdk.BlockNodeApi; |
5 | 5 | import com.hedera.hashgraph.sdk.BlockNodeServiceEndpoint; |
6 | 6 | import com.hedera.hashgraph.sdk.Client; |
| 7 | +import com.hedera.hashgraph.sdk.NodeUpdateTransaction; |
7 | 8 | import com.hedera.hashgraph.sdk.PrivateKey; |
8 | 9 | import com.hedera.hashgraph.sdk.RegisteredNodeCreateTransaction; |
9 | 10 | import com.hedera.hashgraph.sdk.RegisteredNodeDeleteTransaction; |
@@ -127,19 +128,31 @@ public static void main(String[] args) throws Exception { |
127 | 128 | * Step 5: |
128 | 129 | * Add the registeredNodeId as associatedRegisteredNodes to a Node. |
129 | 130 | */ |
130 | | - // TODO |
| 131 | + long registeredNodeId = registeredNodeUpdateTxReceipt.registeredNodeId; |
| 132 | + NodeUpdateTransaction associateTx = new NodeUpdateTransaction() |
| 133 | + .setNodeId(0) |
| 134 | + .addAssociatedRegisteredNode(registeredNodeId) |
| 135 | + .freezeWith(client); |
| 136 | + |
| 137 | + System.out.println("Associating registered node " + registeredNodeId + " with consensus node..."); |
| 138 | + TransactionResponse associateTxResponse = associateTx.execute(client); |
| 139 | + associateTxResponse.getReceipt(client); |
| 140 | + |
131 | 141 |
|
132 | 142 | /* |
133 | 143 | * Step 6: |
134 | 144 | * Delete the Registered Node. |
135 | 145 | */ |
136 | | - RegisteredNodeDeleteTransaction registeredNodeDeleteTx = new RegisteredNodeDeleteTransaction() |
| 146 | + System.out.println("Deleting Registered Node..."); |
| 147 | + new RegisteredNodeDeleteTransaction() |
137 | 148 | .setRegisteredNodeId(registeredNodeCreateTxReceipt.registeredNodeId) |
138 | 149 | .freezeWith(client) |
139 | | - .sign(adminKey); |
| 150 | + .sign(adminKey) |
| 151 | + .execute(client) |
| 152 | + .getReceipt(client); |
140 | 153 |
|
141 | | - System.out.println("Deleting Registered Node..."); |
142 | | - TransactionResponse registeredNodeDeleteTxResponse = registeredNodeDeleteTx.execute(client); |
143 | | - registeredNodeDeleteTxResponse.getReceipt(client); |
| 154 | + client.close(); |
| 155 | + |
| 156 | + System.out.println("Registered Node Lifecycle Example Complete!"); |
144 | 157 | } |
145 | 158 | } |
0 commit comments