Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aergocli: added option to getpeer command #351

Merged
merged 2 commits into from
Oct 15, 2024
Merged

Conversation

hayarobi
Copy link
Member

@hayarobi hayarobi commented Feb 23, 2024

  • Added flag options for --detail=-2
  • new option will show peers with fixed width size
  • it also can show alias name of node.

@kroggen kroggen changed the title Added option to getpeer commands aergocli: added option to getpeer command Feb 24, 2024
usr, _ := user.Current()
dir := usr.HomeDir
aliasPath := filepath.Join(dir, AergoDir, NodeAliasFile)
// If the file doesn't exist, create it, or append to the file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it really create the file?
The code does not append to the file, it only reads from it

Copy link
Member Author

@hayarobi hayarobi Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not write file. The comment seems confusing. I meant that the user, who excutes aergocli, should create the aliasNames file and put to the right place - ~/.aergo/ by himself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will correct the comment.

} else {
res := jsonrpc.ConvShortPeerList(msg)
cmd.Println(jsonrpc.MarshalJSON(res))
}
}

func showPrettyAndShort(cmd *cobra.Command, msg *types.PeerList) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the name starts with "show"? What is this function showing?

"Pretty" and "short" are both adjectives. What is this function printing?

The name is not good

@@ -65,12 +78,74 @@ func execGetPeers(cmd *cobra.Command, args []string) {
// TODO show long fields
res := jsonrpc.ConvLongPeerList(msg)
cmd.Println(jsonrpc.MarshalJSON(res))
} else if detailed == -2 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not the command --detail=2? So why the negative value here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just followed previous conventions, though that convention looks strange. this flag has 3 options; 1 or greater show most verbose informations about connected peers, 0 (default) shows slightly less that 1, and -1 shows compact form of informations that is far from detail. I meant -1 as another type of compact form.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the PR description you wrote --detail=2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a typo, I fixed it just now.

@kroggen
Copy link
Member

kroggen commented Feb 24, 2024

Show an example of output when using the above command
And the normal output so we can compare

@hayarobi
Copy link
Member Author

hayarobi commented Feb 29, 2024

If you can execute aergocli, you can see what are different.

{
 "peers": [
  "16*fJ2CVQ;13.209.29.176/7846;Agent;152880532",
  "16*RAQy6C;172.18.0.2/7846;Watcher;152880513",
  "16*cc71in;10.1.2.186/7846;Producer;152880534",
  "16*Lh3yBS;172.18.0.2/7846;Watcher;152880533",
  "16*JFhSbU;15.165.40.185/7846;Watcher;152880534",
  "16*n2mfEc;10.1.2.223/7846;Producer;152880525",
  "16*ryjide;10.1.2.223/17846;Producer;152880526",
  "16*ApG3J2;172.18.0.2/7846;Watcher;152880513",
  "16*1oHNUu;10.1.2.9/7846;Producer;152880533",
  "16*PVzxQu;10.1.2.174/17846;Producer;152880534",
  "16*G8c2cJ;10.1.2.174/7846;Producer;152880534",
  "16*B6iVhd;54.180.209.184/7846;Agent;152880534",
  "16*N4fvVG;10.1.2.9/17846;Producer;152880527"
 ]
}
 ```bash
aergocli -H mainnet-api.aergo.io getpeers --detail=-2
{
 "peers": [
  "AG03;16*fJ2CVQ;  13.209.29.176/ 7846;    Agent; 152880557",
  "    ;16*RAQy6C;     172.18.0.2/ 7846;  Watcher; 152880550",
  "BP11;16*cc71in;     10.1.2.186/ 7846; Producer; 152880557",
  "    ;16*Lh3yBS;     172.18.0.2/ 7846;  Watcher; 152880545",
  "    ;16*JFhSbU;  15.165.40.185/ 7846;  Watcher; 152880557",
  "BP03;16*n2mfEc;     10.1.2.223/ 7846; Producer; 152880549",
  "BP04;16*ryjide;     10.1.2.223/17846; Producer; 152880551",
  "    ;16*ApG3J2;     172.18.0.2/ 7846;  Watcher; 152880545",
  "BP09;16*1oHNUu;       10.1.2.9/ 7846; Producer; 152880549",
  "BP02;16*PVzxQu;     10.1.2.174/17846; Producer; 152880557",
  "BP01;16*G8c2cJ;     10.1.2.174/ 7846; Producer; 152880557",
  "AG02;16*B6iVhd; 54.180.209.184/ 7846;    Agent; 152880557",
  "BP10;16*N4fvVG;       10.1.2.9/17846; Producer; 152880557"
 ]
}

- new option will show peers with fixed width size
- it also can show alias name of node.
@kroggen
Copy link
Member

kroggen commented Oct 7, 2024

@hayarobi this can be merged if it is ready

@kroggen kroggen merged commit 138a8e6 into develop Oct 15, 2024
3 checks passed
@kroggen kroggen deleted the feat/prettygetpeer branch October 15, 2024 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants