Skip to content

Commit

Permalink
Add diff-pub flag to provider command (#87)
Browse files Browse the repository at this point in the history
* Add diff-pub flag to provider command

Update to latest go-libipni and go-libp2p.

* update version
  • Loading branch information
gammazero authored Dec 19, 2023
1 parent f7cb6db commit 1c98f22
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require (
github.com/ipfs/go-log/v2 v2.5.1
github.com/ipld/go-car/v2 v2.13.1
github.com/ipld/go-ipld-prime v0.21.0
github.com/ipni/go-libipni v0.5.7
github.com/libp2p/go-libp2p v0.32.1
github.com/ipni/go-libipni v0.5.8
github.com/libp2p/go-libp2p v0.32.2
github.com/mattn/go-isatty v0.0.20
github.com/montanaflynn/stats v0.7.0
github.com/multiformats/go-multiaddr v0.12.0
Expand Down Expand Up @@ -120,7 +120,7 @@ require (
github.com/prometheus/procfs v0.11.1 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.3.4 // indirect
github.com/quic-go/quic-go v0.39.3 // indirect
github.com/quic-go/quic-go v0.39.4 // indirect
github.com/quic-go/webtransport-go v0.6.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ github.com/ipld/go-codec-dagpb v1.6.0/go.mod h1:ANzFhfP2uMJxRBr8CE+WQWs5UsNa0pYt
github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E=
github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ=
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20230102063945-1a409dc236dd h1:gMlw/MhNr2Wtp5RwGdsW23cs+yCuj9k2ON7i9MiJlRo=
github.com/ipni/go-libipni v0.5.7 h1:6/JLZGfv3I54ArBKfS+k/ywOCntXtxMcD7qIf8+uexY=
github.com/ipni/go-libipni v0.5.7/go.mod h1:+S7MXdUoYyrKK37clglSJyzIV8AkQYG5TuMZhLIgJek=
github.com/ipni/go-libipni v0.5.8 h1:iSob6WRjdRuKpDZmwYw5aBD13utosnEGlRRun/21ZCs=
github.com/ipni/go-libipni v0.5.8/go.mod h1:QvWhyJAY6CZ6IoQNw0DvZQW2nDJWxt/diwxv8udoAIw=
github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52 h1:QG4CGBqCeuBo6aZlGAamSkxWdgWfZGeE49eUOWJPA4c=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
Expand Down Expand Up @@ -315,8 +315,8 @@ github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38y
github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic=
github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM=
github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro=
github.com/libp2p/go-libp2p v0.32.1 h1:wy1J4kZIZxOaej6NveTWCZmHiJ/kY7GoAqXgqNCnPps=
github.com/libp2p/go-libp2p v0.32.1/go.mod h1:hXXC3kXPlBZ1eu8Q2hptGrMB4mZ3048JUoS4EKaHW5c=
github.com/libp2p/go-libp2p v0.32.2 h1:s8GYN4YJzgUoyeYNPdW7JZeZ5Ee31iNaIBfGYMAY4FQ=
github.com/libp2p/go-libp2p v0.32.2/go.mod h1:E0LKe+diV/ZVJVnOJby8VC5xzHF0660osg71skcxJvk=
github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s=
github.com/libp2p/go-libp2p-asn-util v0.3.0/go.mod h1:B1mcOrKUE35Xq/ASTmQ4tN3LNzVVaMNmq2NACuqyB9w=
github.com/libp2p/go-libp2p-pubsub v0.10.0 h1:wS0S5FlISavMaAbxyQn3dxMOe2eegMfswM471RuHJwA=
Expand Down Expand Up @@ -444,8 +444,8 @@ github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg=
github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
github.com/quic-go/quic-go v0.39.3 h1:o3YB6t2SR+HU/pgwF29kJ6g4jJIJEwEZ8CKia1h1TKg=
github.com/quic-go/quic-go v0.39.3/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q=
github.com/quic-go/quic-go v0.39.4 h1:PelfiuG7wXEffUT2yceiqz5V6Pc0TA5ruOd1LcmFc1s=
github.com/quic-go/quic-go v0.39.4/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q=
github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY=
github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc=
github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk=
Expand Down
29 changes: 17 additions & 12 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ var providerFlags = []cli.Flag{
Name: "distance",
Usage: "Calculate distance from last seen advertisement to provider's current head advertisement",
},
&cli.BoolFlag{
Name: "diff-pub",
Usage: "Only show providers whose publisher ID is different from the provider ID.",
},
&cli.BoolFlag{
Name: "follow-dist",
Aliases: []string{"fd"},
Expand Down Expand Up @@ -182,6 +186,10 @@ func getProvider(cctx *cli.Context, pc *pcache.ProviderCache, peerID peer.ID) er
return errors.New("provider not found on indexer")
}

if cctx.Bool("diff-pub") && prov.AddrInfo.ID == prov.Publisher.ID {
return nil
}

if cctx.Bool("id-only") {
fmt.Println(prov.AddrInfo.ID)
return nil
Expand Down Expand Up @@ -244,18 +252,8 @@ func listProviders(cctx *cli.Context, exclude map[peer.ID]struct{}) error {
onlyWithError = !cctx.Bool("invert")
}

if cctx.Bool("id-only") {
for _, pinfo := range provs {
if _, ok := exclude[pinfo.AddrInfo.ID]; ok {
continue
}
if errFilter && (onlyWithError == (pinfo.LastError == "")) {
continue
}
fmt.Println(pinfo.AddrInfo.ID)
}
return nil
}
diffPub := cctx.Bool("diff-pub")
idOnly := cctx.Bool("id-only")

for _, pinfo := range provs {
if _, ok := exclude[pinfo.AddrInfo.ID]; ok {
Expand All @@ -264,6 +262,13 @@ func listProviders(cctx *cli.Context, exclude map[peer.ID]struct{}) error {
if errFilter && (onlyWithError == (pinfo.LastError == "")) {
continue
}
if diffPub && pinfo.AddrInfo.ID == pinfo.Publisher.ID {
continue
}
if idOnly {
fmt.Println(pinfo.AddrInfo.ID)
continue
}
showProviderInfo(cctx, pinfo)
}

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v0.1.7"
"version": "v0.1.8"
}

0 comments on commit 1c98f22

Please sign in to comment.