From 37da950159c56324fa6538e68e82f5850a939137 Mon Sep 17 00:00:00 2001 From: Bogdan Stirbat Date: Mon, 17 May 2021 19:13:07 +0300 Subject: [PATCH 01/11] refactor(pinmfs): log error if pre-existing pin failed (#8056) * pinmfs: log error if pin failed * refactor: log pre-existing remote mfs pins This cleans up debug logging and ensures we use %q for data read from remote services. We log pre-existing pins for MFS root and print ERROR if pin for current root has status "failed", otherwise, we log to debug. Co-authored-by: Marcin Rataj (cherry picked from commit 075cc8f35674bb30388faa7a3e73099a649cecf6) --- cmd/ipfs/pinmfs.go | 34 ++++++++++++++++++++-------------- cmd/ipfs/pinmfs_test.go | 4 ++-- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/cmd/ipfs/pinmfs.go b/cmd/ipfs/pinmfs.go index 5d17f3013f3..8ea9d2dcc8e 100644 --- a/cmd/ipfs/pinmfs.go +++ b/cmd/ipfs/pinmfs.go @@ -138,9 +138,9 @@ func pinAllMFS(ctx context.Context, node pinMFSNode, cfg *config.Config, rootCid for svcName_, svcConfig_ := range cfg.Pinning.RemoteServices { // skip services where MFS is not enabled svcName, svcConfig := svcName_, svcConfig_ - mfslog.Debugf("pinning considering service %s for mfs pinning", svcName) + mfslog.Debugf("pinning MFS root considering service %q", svcName) if !svcConfig.Policies.MFS.Enable { - mfslog.Debugf("pinning service %s is not enabled", svcName) + mfslog.Debugf("pinning service %q is not enabled", svcName) ch <- lastPin{} continue } @@ -153,7 +153,7 @@ func pinAllMFS(ctx context.Context, node pinMFSNode, cfg *config.Config, rootCid repinInterval, err = time.ParseDuration(svcConfig.Policies.MFS.RepinInterval) if err != nil { select { - case errCh <- fmt.Errorf("remote pinning service %s has invalid MFS.RepinInterval (%v)", svcName, err): + case errCh <- fmt.Errorf("remote pinning service %q has invalid MFS.RepinInterval (%v)", svcName, err): case <-ctx.Done(): } ch <- lastPin{} @@ -165,20 +165,20 @@ func pinAllMFS(ctx context.Context, node pinMFSNode, cfg *config.Config, rootCid if last, ok := lastPins[svcName]; ok { if last.ServiceConfig == svcConfig && (last.CID == rootCid || time.Since(last.Time) < repinInterval) { if last.CID == rootCid { - mfslog.Debugf("pinning MFS root to %s: pin for %s exists since %s, skipping", svcName, rootCid, last.Time.String()) + mfslog.Debugf("pinning MFS root to %q: pin for %q exists since %s, skipping", svcName, rootCid, last.Time.String()) } else { - mfslog.Debugf("pinning MFS root to %s: skipped due to MFS.RepinInterval=%s (remaining: %s)", svcName, repinInterval.String(), (repinInterval - time.Since(last.Time)).String()) + mfslog.Debugf("pinning MFS root to %q: skipped due to MFS.RepinInterval=%s (remaining: %s)", svcName, repinInterval.String(), (repinInterval - time.Since(last.Time)).String()) } ch <- lastPin{} continue } } - mfslog.Debugf("pinning MFS root %s to %s", rootCid, svcName) + mfslog.Debugf("pinning MFS root %q to %q", rootCid, svcName) go func() { if r, err := pinMFS(ctx, node, rootCid, svcName, svcConfig); err != nil { select { - case errCh <- fmt.Errorf("pinning MFS root %s to %s (%v)", rootCid, svcName, err): + case errCh <- fmt.Errorf("pinning MFS root %q to %q (%v)", rootCid, svcName, err): case <-ctx.Done(): } ch <- lastPin{} @@ -212,12 +212,18 @@ func pinMFS( pinStatuses := []pinclient.Status{pinclient.StatusQueued, pinclient.StatusPinning, pinclient.StatusPinned, pinclient.StatusFailed} lsPinCh, lsErrCh := c.Ls(ctx, pinclient.PinOpts.FilterName(pinName), pinclient.PinOpts.FilterStatus(pinStatuses...)) existingRequestID := "" // is there any pre-existing MFS pin with pinName (for any CID)? - alreadyPinned := false // is CID for current MFS already pinned? + pinning := false // is CID for current MFS already being pinned? pinTime := time.Now().UTC() + pinStatusMsg := "pinning to %q: received pre-existing %q status for %q (requestid=%q)" for ps := range lsPinCh { existingRequestID = ps.GetRequestId() + if ps.GetPin().GetCid() == cid && ps.GetStatus() == pinclient.StatusFailed { + mfslog.Errorf(pinStatusMsg, svcName, pinclient.StatusFailed, cid, existingRequestID) + } else { + mfslog.Debugf(pinStatusMsg, svcName, ps.GetStatus(), ps.GetPin().GetCid(), existingRequestID) + } if ps.GetPin().GetCid() == cid && ps.GetStatus() != pinclient.StatusFailed { - alreadyPinned = true + pinning = true pinTime = ps.GetCreated().UTC() break } @@ -228,9 +234,9 @@ func pinMFS( return lastPin{}, fmt.Errorf("error while listing remote pins: %v", err) } - // CID of the current MFS root is already pinned, nothing to do - if alreadyPinned { - mfslog.Debugf("pinning MFS to %s: pin for %s exists since %s, skipping", svcName, cid, pinTime.String()) + // CID of the current MFS root is already being pinned, nothing to do + if pinning { + mfslog.Debugf("pinning MFS to %q: pin for %q exists since %s, skipping", svcName, cid, pinTime.String()) return lastPin{Time: pinTime, ServiceName: svcName, ServiceConfig: svcConfig, CID: cid}, nil } @@ -250,13 +256,13 @@ func pinMFS( // Create or replace pin for MFS root if existingRequestID != "" { - mfslog.Debugf("pinning to %s: replacing existing MFS root pin with %s", svcName, cid) + mfslog.Debugf("pinning to %q: replacing existing MFS root pin with %q", svcName, cid) _, err := c.Replace(ctx, existingRequestID, cid, addOpts...) if err != nil { return lastPin{}, err } } else { - mfslog.Debugf("pinning to %s: creating a new MFS root pin for %s", svcName, cid) + mfslog.Debugf("pinning to %q: creating a new MFS root pin for %q", svcName, cid) _, err := c.Add(ctx, cid, addOpts...) if err != nil { return lastPin{}, err diff --git a/cmd/ipfs/pinmfs_test.go b/cmd/ipfs/pinmfs_test.go index 42ffe9d408e..e38e196beb3 100644 --- a/cmd/ipfs/pinmfs_test.go +++ b/cmd/ipfs/pinmfs_test.go @@ -9,7 +9,7 @@ import ( config "github.com/ipfs/go-ipfs-config" ipld "github.com/ipfs/go-ipld-format" - "github.com/ipfs/go-merkledag" + merkledag "github.com/ipfs/go-merkledag" "github.com/libp2p/go-libp2p-core/host" peer "github.com/libp2p/go-libp2p-core/peer" ) @@ -149,7 +149,7 @@ func TestPinMFSService(t *testing.T) { }, }, } - testPinMFSServiceWithError(t, cfg_invalid_interval, "remote pinning service invalid_interval has invalid MFS.RepinInterval") + testPinMFSServiceWithError(t, cfg_invalid_interval, "remote pinning service \"invalid_interval\" has invalid MFS.RepinInterval") testPinMFSServiceWithError(t, cfg_valid_unnamed, "error while listing remote pins: empty response from remote pinning service") testPinMFSServiceWithError(t, cfg_valid_named, "error while listing remote pins: empty response from remote pinning service") } From 0b59e5ede7ba1309ceb57e4fae3c1557660744bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 May 2021 11:14:10 +0000 Subject: [PATCH 02/11] build(deps): bump github.com/ipfs/go-bitswap from 0.3.3 to 0.3.4 Bumps [github.com/ipfs/go-bitswap](https://github.com/ipfs/go-bitswap) from 0.3.3 to 0.3.4. - [Release notes](https://github.com/ipfs/go-bitswap/releases) - [Commits](https://github.com/ipfs/go-bitswap/compare/v0.3.3...v0.3.4) Signed-off-by: dependabot[bot] (cherry picked from commit 6a029a48ab16a9828a35ff067b139455449e4b64) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 99c39198158..4d69e9ff55c 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/gabriel-vasile/mimetype v1.2.0 github.com/go-bindata/go-bindata/v3 v3.1.3 github.com/hashicorp/go-multierror v1.1.1 - github.com/ipfs/go-bitswap v0.3.3 + github.com/ipfs/go-bitswap v0.3.4 github.com/ipfs/go-block-format v0.0.3 github.com/ipfs/go-blockservice v0.1.4 github.com/ipfs/go-cid v0.0.7 diff --git a/go.sum b/go.sum index 49d9cc81d40..208818f43e3 100644 --- a/go.sum +++ b/go.sum @@ -343,8 +343,8 @@ github.com/ipfs/go-bitswap v0.1.0/go.mod h1:FFJEf18E9izuCqUtHxbWEvq+reg7o4CW5wSA github.com/ipfs/go-bitswap v0.1.2/go.mod h1:qxSWS4NXGs7jQ6zQvoPY3+NmOfHHG47mhkiLzBpJQIs= github.com/ipfs/go-bitswap v0.1.3/go.mod h1:YEQlFy0kkxops5Vy+OxWdRSEZIoS7I7KDIwoa5Chkps= github.com/ipfs/go-bitswap v0.1.8/go.mod h1:TOWoxllhccevbWFUR2N7B1MTSVVge1s6XSMiCSA4MzM= -github.com/ipfs/go-bitswap v0.3.3 h1:CrTO3OiOYFBcdliw074/C7T2QYHEOsPClgvR6RIYcO4= -github.com/ipfs/go-bitswap v0.3.3/go.mod h1:AyWWfN3moBzQX0banEtfKOfbXb3ZeoOeXnZGNPV9S6w= +github.com/ipfs/go-bitswap v0.3.4 h1:AhJhRrG8xkxh6x87b4wWs+4U4y3DVB3doI8yFNqgQME= +github.com/ipfs/go-bitswap v0.3.4/go.mod h1:4T7fvNv/LmOys+21tnLzGKncMeeXUYUd1nUiJ2teMvI= github.com/ipfs/go-block-format v0.0.1/go.mod h1:DK/YYcsSUIVAFNwo/KZCdIIbpN0ROH/baNLgayt4pFc= github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY= github.com/ipfs/go-block-format v0.0.3 h1:r8t66QstRp/pd/or4dpnbVfXT5Gt7lOqRvC+/dDTpMc= From 7a8126bc0a33be1977d1730962fbb5cd3c0b7024 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 May 2021 11:17:09 +0000 Subject: [PATCH 03/11] build(deps): bump github.com/libp2p/go-doh-resolver from 0.3.0 to 0.3.1 Bumps [github.com/libp2p/go-doh-resolver](https://github.com/libp2p/go-doh-resolver) from 0.3.0 to 0.3.1. - [Release notes](https://github.com/libp2p/go-doh-resolver/releases) - [Commits](https://github.com/libp2p/go-doh-resolver/compare/v0.3.0...v0.3.1) Signed-off-by: dependabot[bot] (cherry picked from commit 482d7ed532bedf8f74fbc823e7fa2363277e96bb) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4d69e9ff55c..5acc27789ab 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c github.com/jbenet/go-temp-err-catcher v0.1.0 github.com/jbenet/goprocess v0.1.4 - github.com/libp2p/go-doh-resolver v0.3.0 + github.com/libp2p/go-doh-resolver v0.3.1 github.com/libp2p/go-libp2p v0.14.0 github.com/libp2p/go-libp2p-circuit v0.4.0 github.com/libp2p/go-libp2p-connmgr v0.2.4 diff --git a/go.sum b/go.sum index 208818f43e3..47263467151 100644 --- a/go.sum +++ b/go.sum @@ -589,8 +589,8 @@ github.com/libp2p/go-conn-security-multistream v0.2.1 h1:ft6/POSK7F+vl/2qzegnHDa github.com/libp2p/go-conn-security-multistream v0.2.1 h1:ft6/POSK7F+vl/2qzegnHDaXFU0iWB4yVTYrioC6Zy0= github.com/libp2p/go-conn-security-multistream v0.2.1/go.mod h1:cR1d8gA0Hr59Fj6NhaTpFhJZrjSYuNmhpT2r25zYR70= github.com/libp2p/go-conn-security-multistream v0.2.1/go.mod h1:cR1d8gA0Hr59Fj6NhaTpFhJZrjSYuNmhpT2r25zYR70= -github.com/libp2p/go-doh-resolver v0.3.0 h1:YePXUmvjyFT7NsqgnEkhEi5d/Nqab97QZf7BPNUWSqo= -github.com/libp2p/go-doh-resolver v0.3.0/go.mod h1:y5go1ZppAq9N2eppbX0xON01CyPBeUg2yS6BTssssog= +github.com/libp2p/go-doh-resolver v0.3.1 h1:1wbVGkB4Tdj4WEvjAuYknOPyt4vSSDn9thnj13pKPaY= +github.com/libp2p/go-doh-resolver v0.3.1/go.mod h1:y5go1ZppAq9N2eppbX0xON01CyPBeUg2yS6BTssssog= github.com/libp2p/go-eventbus v0.1.0/go.mod h1:vROgu5cs5T7cv7POWlWxBaVLxfSegC5UGQf8A2eEmx4= github.com/libp2p/go-eventbus v0.2.1 h1:VanAdErQnpTioN2TowqNcOijf6YwhuODe4pPKSDpxGc= github.com/libp2p/go-eventbus v0.2.1/go.mod h1:jc2S4SoEVPP48H9Wpzm5aiGwUCBMfGhVhhBjyhhCJs8= From 99b22425b5d656cd743d1b1ead91525dbca7dbde Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 21 May 2021 19:01:34 +0200 Subject: [PATCH 04/11] fix: webui-2.12.3 This bumps webui to bugfix release based on feedback from 0.9.0-rc1: https://github.com/ipfs/ipfs-webui/releases/tag/v2.12.3 (cherry picked from commit 2c431eb825b3a8ab39eafdf29c41fcc4c25c529d) --- core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/corehttp/webui.go b/core/corehttp/webui.go index 6191119cab9..8bff09a6b4b 100644 --- a/core/corehttp/webui.go +++ b/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeifuexpvt6g4bkbmsrlb7rnudskfakn6vdrtoja4ml4zbxne2hu6bq" // v2.12.2 +const WebUIPath = "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq" // v2.12.3 // this is a list of all past webUI paths. var WebUIPaths = []string{ From 0aaf31d991cae1351cc0bf8c5c5881ad1d63796e Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Tue, 25 May 2021 19:00:14 -0400 Subject: [PATCH 05/11] chore: update deps (cherry picked from commit 3746c2d63052df6a608486153f49d6241b30ae45) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 5acc27789ab..6f749b73b19 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/ipfs/go-ipfs-keystore v0.0.2 github.com/ipfs/go-ipfs-pinner v0.1.1 github.com/ipfs/go-ipfs-posinfo v0.0.1 - github.com/ipfs/go-ipfs-provider v0.4.4-0.20210513014626-1c19caa05024 + github.com/ipfs/go-ipfs-provider v0.5.1 github.com/ipfs/go-ipfs-routing v0.1.0 github.com/ipfs/go-ipfs-util v0.0.2 github.com/ipfs/go-ipld-cbor v0.0.5 @@ -65,7 +65,7 @@ require ( github.com/libp2p/go-libp2p-core v0.8.5 github.com/libp2p/go-libp2p-discovery v0.5.0 github.com/libp2p/go-libp2p-http v0.2.0 - github.com/libp2p/go-libp2p-kad-dht v0.12.0 + github.com/libp2p/go-libp2p-kad-dht v0.12.1 github.com/libp2p/go-libp2p-kbucket v0.4.7 github.com/libp2p/go-libp2p-loggables v0.1.0 github.com/libp2p/go-libp2p-mplex v0.4.1 diff --git a/go.sum b/go.sum index 47263467151..c042727aec0 100644 --- a/go.sum +++ b/go.sum @@ -436,8 +436,8 @@ github.com/ipfs/go-ipfs-posinfo v0.0.1/go.mod h1:SwyeVP+jCwiDu0C313l/8jg6ZxM0qqt github.com/ipfs/go-ipfs-pq v0.0.1/go.mod h1:LWIqQpqfRG3fNc5XsnIhz/wQ2XXGyugQwls7BgUmUfY= github.com/ipfs/go-ipfs-pq v0.0.2 h1:e1vOOW6MuOwG2lqxcLA+wEn93i/9laCY8sXAw76jFOY= github.com/ipfs/go-ipfs-pq v0.0.2/go.mod h1:LWIqQpqfRG3fNc5XsnIhz/wQ2XXGyugQwls7BgUmUfY= -github.com/ipfs/go-ipfs-provider v0.4.4-0.20210513014626-1c19caa05024 h1:eYfdZ27ogtwfnwKdfphOwcQ7PEOjKqXlWzVOakK0a60= -github.com/ipfs/go-ipfs-provider v0.4.4-0.20210513014626-1c19caa05024/go.mod h1:kUMTf1R8c+KgWUWKTGSZiXCDZWMCkxCX3wyepk0cYEA= +github.com/ipfs/go-ipfs-provider v0.5.1 h1:kZj72jzWLtGcorlwnMvBL6y6KJk6klO2Kb8QSeqEB0o= +github.com/ipfs/go-ipfs-provider v0.5.1/go.mod h1:fem6HKSru7n35Ljap6kowWdJrUzvcWJW01uhAkqNnzo= github.com/ipfs/go-ipfs-routing v0.0.1/go.mod h1:k76lf20iKFxQTjcJokbPM9iBXVXVZhcOwc360N4nuKs= github.com/ipfs/go-ipfs-routing v0.1.0 h1:gAJTT1cEeeLj6/DlLX6t+NxD9fQe2ymTO6qWRDI/HQQ= github.com/ipfs/go-ipfs-routing v0.1.0/go.mod h1:hYoUkJLyAUKhF58tysKpids8RNDPO42BVMgK5dNsoqY= @@ -679,8 +679,8 @@ github.com/libp2p/go-libp2p-interface-connmgr v0.0.4/go.mod h1:GarlRLH0LdeWcLnYM github.com/libp2p/go-libp2p-interface-connmgr v0.0.5/go.mod h1:GarlRLH0LdeWcLnYM/SaBykKFl9U5JFnbBGruAk/D5k= github.com/libp2p/go-libp2p-interface-pnet v0.0.1/go.mod h1:el9jHpQAXK5dnTpKA4yfCNBZXvrzdOU75zz+C6ryp3k= github.com/libp2p/go-libp2p-kad-dht v0.11.1/go.mod h1:5ojtR2acDPqh/jXf5orWy8YGb8bHQDS+qeDcoscL/PI= -github.com/libp2p/go-libp2p-kad-dht v0.12.0 h1:R5vvp8kuXjsyDE/HEMKgM8XIwlRsP5BdAZexM+tJxdU= -github.com/libp2p/go-libp2p-kad-dht v0.12.0/go.mod h1:zdQYru1c7dnluMpZls4i9Fj2TwYXS7YyDkJ1Yahv0w0= +github.com/libp2p/go-libp2p-kad-dht v0.12.1 h1:6HsBhzxcD34rE7Ds2lK9q6llPE7/tdqV7JmJiukEcQ8= +github.com/libp2p/go-libp2p-kad-dht v0.12.1/go.mod h1:zdQYru1c7dnluMpZls4i9Fj2TwYXS7YyDkJ1Yahv0w0= github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio= github.com/libp2p/go-libp2p-kbucket v0.4.7 h1:spZAcgxifvFZHBD8tErvppbnNiKA5uokDu3CV7axu70= github.com/libp2p/go-libp2p-kbucket v0.4.7/go.mod h1:XyVo99AfQH0foSf176k4jY1xUJ2+jUJIZCSDm7r2YKk= From f877b05290c12e199dc08e5e73e448d702d5a071 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Tue, 25 May 2021 17:47:58 -0400 Subject: [PATCH 06/11] feat: add a text output encoding for the stats provide command (cherry picked from commit 37de3d0586928a3d3373a07c864d4d894d4de276) --- core/commands/stat_provide.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/core/commands/stat_provide.go b/core/commands/stat_provide.go index ac02c344cd6..073bae159a3 100644 --- a/core/commands/stat_provide.go +++ b/core/commands/stat_provide.go @@ -2,6 +2,8 @@ package commands import ( "fmt" + "io" + "text/tabwriter" cmds "github.com/ipfs/go-ipfs-cmds" "github.com/ipfs/go-ipfs/core/commands/cmdenv" @@ -46,6 +48,17 @@ This interface is not stable and may change from release to release. return nil }, - Encoders: cmds.EncoderMap{}, - Type: batched.BatchedProviderStats{}, + Encoders: cmds.EncoderMap{ + cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, s *batched.BatchedProviderStats) error { + wtr := tabwriter.NewWriter(w, 0, 0, 1, ' ', 0) + defer wtr.Flush() + + fmt.Fprintf(wtr, "TotalProvides: %d\n", s.TotalProvides) + fmt.Fprintf(wtr, "AvgProvideDuration: %v\n", s.AvgProvideDuration) + fmt.Fprintf(wtr, "LastReprovideDuration: %v\n", s.LastReprovideDuration) + fmt.Fprintf(wtr, "LastReprovideBatchSize: %d\n", s.LastReprovideBatchSize) + return nil + }), + }, + Type: batched.BatchedProviderStats{}, } From 7cb340b0c7ec065bd9e7903a8a95f91283e45ac1 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 27 May 2021 16:22:55 +0200 Subject: [PATCH 07/11] feat: humanized numbers in stat provide https://github.com/ipfs/go-ipfs/pull/8154#discussion_r639231040 (cherry picked from commit c082c73135d4bf9ba44fcc901d84434ed78a652c) --- core/commands/stat_provide.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/core/commands/stat_provide.go b/core/commands/stat_provide.go index 073bae159a3..7d9c44cd0df 100644 --- a/core/commands/stat_provide.go +++ b/core/commands/stat_provide.go @@ -5,6 +5,7 @@ import ( "io" "text/tabwriter" + humanize "github.com/dustin/go-humanize" cmds "github.com/ipfs/go-ipfs-cmds" "github.com/ipfs/go-ipfs/core/commands/cmdenv" @@ -50,15 +51,26 @@ This interface is not stable and may change from release to release. }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, s *batched.BatchedProviderStats) error { - wtr := tabwriter.NewWriter(w, 0, 0, 1, ' ', 0) + wtr := tabwriter.NewWriter(w, 1, 2, 1, ' ', 0) defer wtr.Flush() - fmt.Fprintf(wtr, "TotalProvides: %d\n", s.TotalProvides) - fmt.Fprintf(wtr, "AvgProvideDuration: %v\n", s.AvgProvideDuration) - fmt.Fprintf(wtr, "LastReprovideDuration: %v\n", s.LastReprovideDuration) - fmt.Fprintf(wtr, "LastReprovideBatchSize: %d\n", s.LastReprovideBatchSize) + tp := float64(s.TotalProvides) + fmt.Fprintf(wtr, "TotalProvides:\t%s\t(%s)\n", humanSI(tp, 0), humanFull(tp, 0)) + fmt.Fprintf(wtr, "AvgProvideDuration:\t%v\n", s.AvgProvideDuration) + fmt.Fprintf(wtr, "LastReprovideDuration:\t%v\n", s.LastReprovideDuration) + lrbs := float64(s.LastReprovideBatchSize) + fmt.Fprintf(wtr, "LastReprovideBatchSize:\t%s\t(%s)\n", humanSI(lrbs, 0), humanFull(lrbs, 0)) return nil }), }, Type: batched.BatchedProviderStats{}, } + +func humanSI(val float64, decimals int) string { + v, unit := humanize.ComputeSI(val) + return humanize.SIWithDigits(v, decimals, unit) +} + +func humanFull(val float64, decimals int) string { + return humanize.CommafWithDigits(val, decimals) +} From ad26b278a4b0eed25a9cd2e7d67e27a508c1a9d0 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 27 May 2021 16:49:13 +0200 Subject: [PATCH 08/11] feat: humanized durations in stat provide (cherry picked from commit e5ac70456dadd6723833d67c5cb6dd53b0d880cf) --- core/commands/stat_provide.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/commands/stat_provide.go b/core/commands/stat_provide.go index 7d9c44cd0df..86fe96efb99 100644 --- a/core/commands/stat_provide.go +++ b/core/commands/stat_provide.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "text/tabwriter" + "time" humanize "github.com/dustin/go-humanize" cmds "github.com/ipfs/go-ipfs-cmds" @@ -56,8 +57,8 @@ This interface is not stable and may change from release to release. tp := float64(s.TotalProvides) fmt.Fprintf(wtr, "TotalProvides:\t%s\t(%s)\n", humanSI(tp, 0), humanFull(tp, 0)) - fmt.Fprintf(wtr, "AvgProvideDuration:\t%v\n", s.AvgProvideDuration) - fmt.Fprintf(wtr, "LastReprovideDuration:\t%v\n", s.LastReprovideDuration) + fmt.Fprintf(wtr, "AvgProvideDuration:\t%v\n", humanDuration(s.AvgProvideDuration)) + fmt.Fprintf(wtr, "LastReprovideDuration:\t%v\n", humanDuration(s.LastReprovideDuration)) lrbs := float64(s.LastReprovideBatchSize) fmt.Fprintf(wtr, "LastReprovideBatchSize:\t%s\t(%s)\n", humanSI(lrbs, 0), humanFull(lrbs, 0)) return nil @@ -66,6 +67,10 @@ This interface is not stable and may change from release to release. Type: batched.BatchedProviderStats{}, } +func humanDuration(val time.Duration) string { + return val.Truncate(time.Microsecond).String() +} + func humanSI(val float64, decimals int) string { v, unit := humanize.ComputeSI(val) return humanize.SIWithDigits(v, decimals, unit) From 8880c92e2f4ece744877bff0ec2c92aeeb91565b Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 27 May 2021 22:03:11 +0200 Subject: [PATCH 09/11] refactor: improved humanNumber and humanSI This hides "(n)" when value is same as SI, and makes SI "3k" (instead of "3 k") (cherry picked from commit f40dc731e9d7e3d452d03c632d99ef9577d1fb2d) --- core/commands/stat_provide.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/core/commands/stat_provide.go b/core/commands/stat_provide.go index 86fe96efb99..4224efcafc0 100644 --- a/core/commands/stat_provide.go +++ b/core/commands/stat_provide.go @@ -55,12 +55,10 @@ This interface is not stable and may change from release to release. wtr := tabwriter.NewWriter(w, 1, 2, 1, ' ', 0) defer wtr.Flush() - tp := float64(s.TotalProvides) - fmt.Fprintf(wtr, "TotalProvides:\t%s\t(%s)\n", humanSI(tp, 0), humanFull(tp, 0)) - fmt.Fprintf(wtr, "AvgProvideDuration:\t%v\n", humanDuration(s.AvgProvideDuration)) - fmt.Fprintf(wtr, "LastReprovideDuration:\t%v\n", humanDuration(s.LastReprovideDuration)) - lrbs := float64(s.LastReprovideBatchSize) - fmt.Fprintf(wtr, "LastReprovideBatchSize:\t%s\t(%s)\n", humanSI(lrbs, 0), humanFull(lrbs, 0)) + fmt.Fprintf(wtr, "TotalProvides:\t%s\n", humanNumber(s.TotalProvides)) + fmt.Fprintf(wtr, "AvgProvideDuration:\t%s\n", humanDuration(s.AvgProvideDuration)) + fmt.Fprintf(wtr, "LastReprovideDuration:\t%s\n", humanDuration(s.LastReprovideDuration)) + fmt.Fprintf(wtr, "LastReprovideBatchSize:\t%s\n", humanNumber(s.LastReprovideBatchSize)) return nil }), }, @@ -71,9 +69,19 @@ func humanDuration(val time.Duration) string { return val.Truncate(time.Microsecond).String() } +func humanNumber(n int) string { + nf := float64(n) + str := humanSI(nf, 0) + fullStr := humanFull(nf, 0) + if str != fullStr { + return fmt.Sprintf("%s\t(%s)", str, fullStr) + } + return str +} + func humanSI(val float64, decimals int) string { v, unit := humanize.ComputeSI(val) - return humanize.SIWithDigits(v, decimals, unit) + return fmt.Sprintf("%s%s", humanFull(v, decimals), unit) } func humanFull(val float64, decimals int) string { From 7e8d8733373b95b33f0316c54733ec10ef09a86b Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Thu, 27 May 2021 15:42:16 -0400 Subject: [PATCH 10/11] chore: update go-libp2p-yamux (cherry picked from commit 9c8b1019e5f07632d1f55a1ac4d0b15af599fe2f) --- go.mod | 2 +- go.sum | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6f749b73b19..d10e06626aa 100644 --- a/go.mod +++ b/go.mod @@ -79,7 +79,7 @@ require ( github.com/libp2p/go-libp2p-swarm v0.5.0 github.com/libp2p/go-libp2p-testing v0.4.0 github.com/libp2p/go-libp2p-tls v0.1.3 - github.com/libp2p/go-libp2p-yamux v0.5.3 + github.com/libp2p/go-libp2p-yamux v0.5.4 github.com/libp2p/go-socket-activation v0.0.2 github.com/libp2p/go-tcp-transport v0.2.2 github.com/libp2p/go-ws-transport v0.4.0 diff --git a/go.sum b/go.sum index c042727aec0..0bce975b82c 100644 --- a/go.sum +++ b/go.sum @@ -793,8 +793,9 @@ github.com/libp2p/go-libp2p-yamux v0.2.8/go.mod h1:/t6tDqeuZf0INZMTgd0WxIRbtK2Ez github.com/libp2p/go-libp2p-yamux v0.4.0/go.mod h1:+DWDjtFMzoAwYLVkNZftoucn7PelNoy5nm3tZ3/Zw30= github.com/libp2p/go-libp2p-yamux v0.5.0/go.mod h1:AyR8k5EzyM2QN9Bbdg6X1SkVVuqLwTGf0L4DFq9g6po= github.com/libp2p/go-libp2p-yamux v0.5.1/go.mod h1:dowuvDu8CRWmr0iqySMiSxK+W0iL5cMVO9S94Y6gkv4= -github.com/libp2p/go-libp2p-yamux v0.5.3 h1:x2bK2BWktdMdTrciiDmgTMIxYNBdkxewQFEjHDl7VgU= github.com/libp2p/go-libp2p-yamux v0.5.3/go.mod h1:Vy3TMonBAfTMXHWopsMc8iX/XGRYrRlpUaMzaeuHV/s= +github.com/libp2p/go-libp2p-yamux v0.5.4 h1:/UOPtT/6DHPtr3TtKXBHa6g0Le0szYuI33Xc/Xpd7fQ= +github.com/libp2p/go-libp2p-yamux v0.5.4/go.mod h1:tfrXbyaTqqSU654GTvK3ocnSZL3BuHoeTSqhcel1wsE= github.com/libp2p/go-maddr-filter v0.0.1/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= github.com/libp2p/go-maddr-filter v0.0.4/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= github.com/libp2p/go-maddr-filter v0.0.5/go.mod h1:Jk+36PMfIqCJhAnaASRH83bdAvfDRp/w6ENFaC9bG+M= @@ -874,8 +875,9 @@ github.com/libp2p/go-yamux v1.4.0/go.mod h1:fr7aVgmdNGJK+N1g+b6DW6VxzbRCjCOejR/h github.com/libp2p/go-yamux v1.4.1 h1:P1Fe9vF4th5JOxxgQvfbOHkrGqIZniTLf+ddhZp8YTI= github.com/libp2p/go-yamux v1.4.1/go.mod h1:fr7aVgmdNGJK+N1g+b6DW6VxzbRCjCOejR/hkmpooHE= github.com/libp2p/go-yamux/v2 v2.0.0/go.mod h1:NVWira5+sVUIU6tu1JWvaRn1dRnG+cawOJiflsAM+7U= -github.com/libp2p/go-yamux/v2 v2.1.1 h1:3RkXAnDmaXJPckF/QbDnNbA6lZXMgycNTVMMTQ2YlAI= github.com/libp2p/go-yamux/v2 v2.1.1/go.mod h1:3So6P6TV6r75R9jiBpiIKgU/66lOarCZjqROGxzPpPQ= +github.com/libp2p/go-yamux/v2 v2.2.0 h1:RwtpYZ2/wVviZ5+3pjC8qdQ4TKnrak0/E01N1UWoAFU= +github.com/libp2p/go-yamux/v2 v2.2.0/go.mod h1:3So6P6TV6r75R9jiBpiIKgU/66lOarCZjqROGxzPpPQ= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lucas-clemente/quic-go v0.19.3/go.mod h1:ADXpNbTQjq1hIzCpB+y/k5iz4n4z4IwqoLb94Kh5Hu8= From 947d3d2067930ec7fb1268ff40cdb69bd4d0a505 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Thu, 27 May 2021 15:19:15 -0400 Subject: [PATCH 11/11] Release v0.9.0-rc2 --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index d3f4916d6dd..6f3267f9619 100644 --- a/version.go +++ b/version.go @@ -4,7 +4,7 @@ package ipfs var CurrentCommit string // CurrentVersionNumber is the current application's version literal -const CurrentVersionNumber = "0.9.0-rc1" +const CurrentVersionNumber = "0.9.0-rc2" const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/"