Skip to content

Commit 6a4555c

Browse files
committed
chore: completed example
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent 443f1f0 commit 6a4555c

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

examples/src/main/java/com/hedera/hashgraph/sdk/examples/RegisteredNodeLifeCycleExample.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.hedera.hashgraph.sdk.BlockNodeApi;
55
import com.hedera.hashgraph.sdk.BlockNodeServiceEndpoint;
66
import com.hedera.hashgraph.sdk.Client;
7+
import com.hedera.hashgraph.sdk.NodeUpdateTransaction;
78
import com.hedera.hashgraph.sdk.PrivateKey;
89
import com.hedera.hashgraph.sdk.RegisteredNodeCreateTransaction;
910
import com.hedera.hashgraph.sdk.RegisteredNodeDeleteTransaction;
@@ -127,19 +128,31 @@ public static void main(String[] args) throws Exception {
127128
* Step 5:
128129
* Add the registeredNodeId as associatedRegisteredNodes to a Node.
129130
*/
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+
131141

132142
/*
133143
* Step 6:
134144
* Delete the Registered Node.
135145
*/
136-
RegisteredNodeDeleteTransaction registeredNodeDeleteTx = new RegisteredNodeDeleteTransaction()
146+
System.out.println("Deleting Registered Node...");
147+
new RegisteredNodeDeleteTransaction()
137148
.setRegisteredNodeId(registeredNodeCreateTxReceipt.registeredNodeId)
138149
.freezeWith(client)
139-
.sign(adminKey);
150+
.sign(adminKey)
151+
.execute(client)
152+
.getReceipt(client);
140153

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!");
144157
}
145158
}

0 commit comments

Comments
 (0)