-
Notifications
You must be signed in to change notification settings - Fork 46
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
Conversation
cmd/aergocli/cmd/getpeers.go
Outdated
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
cmd/aergocli/cmd/getpeers.go
Outdated
} else { | ||
res := jsonrpc.ConvShortPeerList(msg) | ||
cmd.Println(jsonrpc.MarshalJSON(res)) | ||
} | ||
} | ||
|
||
func showPrettyAndShort(cmd *cobra.Command, msg *types.PeerList) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Show an example of output when using the above command |
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.
88329a8
to
62a7d3a
Compare
@hayarobi this can be merged if it is ready |
--detail=-2