Skip to content

Commit

Permalink
cpinger: fix minor bug and optimize koios query for discovering, adde…
Browse files Browse the repository at this point in the history
…d version
  • Loading branch information
safanaj committed May 11, 2023
1 parent 9792f27 commit 23a4b97
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cli/cpinger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ import (
koioscli "github.com/safanaj/cardano-go/koios"
)

var (
version string = "0.0.0"
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "cardano-pinger",
Short: "A CLI application to ping cardano nodes and get tip.",
SilenceUsage: true,
SilenceErrors: true,
RunE: runE,
Version: version,
}

func init() {
Expand Down Expand Up @@ -80,10 +85,12 @@ func runE(cmd *cobra.Command, args []string) error {
}
results := map[string]bool{}
resCh := make(chan result)
collectorDoneCh := make(chan struct{})
go func() {
for res := range resCh {
results[res.n] = res.r
}
close(collectorDoneCh)
}()

var wg sync.WaitGroup
Expand All @@ -101,6 +108,7 @@ func runE(cmd *cobra.Command, args []string) error {
}
wg.Wait()
close(resCh)
<-collectorDoneCh

for r, v := range results {
if v {
Expand Down Expand Up @@ -253,7 +261,9 @@ func discoverRelays(ctx context.Context, pool string) ([]string, error) {
}
node := koioscli.NewNode(cardano.Mainnet, ctx)
kc := node.(*koioscli.KoiosCli)
resp, err := kc.GetPoolInfo(ctx, poolId, nil)
opts := kc.NewRequestOptions()
opts.QuerySet("select", "relays")
resp, err := kc.GetPoolInfo(ctx, poolId, opts)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 23a4b97

Please sign in to comment.