-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: started adding a yachli example and taskfile (#1132)
Signed-off-by: Alex Kuzmin <[email protected]> Signed-off-by: Jeromy Cannon <[email protected]> Co-authored-by: Alex Kuzmin <[email protected]>
- Loading branch information
1 parent
2b48f4e
commit 8753723
Showing
34 changed files
with
979 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output/ | ||
syserr.log | ||
/localhost/sysfiles/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Yahcli Address Book Example | ||
|
||
This is an example of how to use Yahcli to pull the ledger and mirror node address book. And to update the ledger address book. It updates File 101 (the ledger address book file) and File 102 (the ledger node details file). | ||
|
||
NOTE: Mirror Node refers to File 102 as its address book. | ||
|
||
## Usage | ||
|
||
To get the address book from the ledger, this requires a port forward to be setup on port 50211 to consensus node with node ID = 0. | ||
```bash | ||
# try and detect if the port forward is already setup | ||
netstat -na | grep 50211 | ||
ps -ef | grep 50211 | grep -v grep | ||
|
||
# setup a port forward if you need to | ||
kubectl port-forward -n "${SOLO_NAMESPACE}" pod/network-node1-0 50211:50211 | ||
``` | ||
|
||
To get the address book from the ledger, run the following command: | ||
```bash | ||
cd <solo-root>/examples/address-book | ||
task get:ledger:addressbook | ||
``` | ||
It will output the address book in JSON format to: | ||
* `examples/address-book/localhost/sysfiles/addressBook.json` | ||
* `examples/address-book/localhost/sysfiles/nodeDetails.json` | ||
|
||
You can update the address book files with your favorite text editor. | ||
|
||
Once the files are ready, you can upload them to the ledger by running the following command: | ||
```bash | ||
cd <solo-root>/examples/address-book | ||
task update:ledger:addressbook | ||
``` | ||
|
||
To get the address book from the mirror node, run the following command: | ||
```bash | ||
cd <solo-root>/examples/address-book | ||
task get:mirror:addressbook | ||
``` | ||
NOTE: Mirror Node may not pick up the changes automatically, it might require running some transactions through, example: | ||
```bash | ||
cd <solo-root> | ||
npm run solo -- account create | ||
npm run solo -- account create | ||
npm run solo -- account create | ||
npm run solo -- account create | ||
npm run solo -- account create | ||
npm run solo -- account update -n solo-e2e --account-id 0.0.1004 --hbar-amount 78910 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
version: 3 | ||
tasks: | ||
get:ledger:addressbook: | ||
silent: true | ||
desc: retrieve the address book (file 101; examples/address-book/localhost/sysfiles/addressBook.json) and node details (file 102; examples/address-book/localhost/sysfiles/nodeDetails.json) from the ledger | ||
cmds: | ||
- java -jar yahcli.jar --verbose=WARN -n localhost -p 2 sysfiles download 102 | ||
- java -jar yahcli.jar --verbose=WARN -n localhost -p 2 sysfiles download 101 | ||
- echo "cat file 102 = localhost/sysfiles/nodeDetails.json" | ||
- echo "---------------------------------------" | ||
- cat localhost/sysfiles/nodeDetails.json | ||
- echo "---------------------------------------" | ||
- echo "cat file 101 = localhost/sysfiles/addressBook.json" | ||
- echo "---------------------------------------" | ||
- cat localhost/sysfiles/addressBook.json | ||
|
||
update:ledger:addressbook: | ||
silent: true | ||
desc: update the address book (file 101; examples/address-book/localhost/sysfiles/addressBook.json) and node details (file 102; examples/address-book/localhost/sysfiles/nodeDetails.json) on the ledger | ||
cmds: | ||
- java -jar yahcli.jar --verbose=WARN -n localhost -p 2 sysfiles upload 102 | ||
- java -jar yahcli.jar --verbose=WARN -n localhost -p 2 sysfiles upload 101 | ||
|
||
get:mirror:addressbook: | ||
silent: true | ||
desc: retrieve the address book from the mirror node (file 102) | ||
cmds: | ||
- | | ||
jq --version > /dev/null 2>&1 | ||
if [[ $? -eq 0 ]]; then | ||
curl -s http://localhost:5551/api/v1/network/nodes | jq | ||
else | ||
curl -s http://localhost:5551/api/v1/network/nodes | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
defaultNetwork: localhost | ||
networks: | ||
localhost: | ||
allowedReceiverAccountIds: [] | ||
nodes: | ||
- { id: 0, account: 3, ipv4Addr: 127.0.0.1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
swirlds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-----BEGIN ENCRYPTED PRIVATE KEY----- | ||
MIHDMH8GCSqGSIb3DQEFDTByMFEGCSqGSIb3DQEFDDBEBDAqNosoP7Vz+faodhk1 | ||
2N4Lykgs3AjiaZws0sajodGNLax8pG0FIFarGWtJyRPSKvgCAicQMAwGCCqGSIb3 | ||
DQIKBQAwHQYJYIZIAWUDBAEqBBC6ckCkLqfdzlIynrvwtracBECvr1K4KI1PWJ5z | ||
YY7WKfjy57ffuuQ2GlNZUrp6yylRlRPGqZ015XT2Cbph6sZNE4xwn0NMxGp7Wf2f | ||
j0A8/Il/ | ||
-----END ENCRYPTED PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
myOHiYnunypq |
Oops, something went wrong.