From d35a853adfa285f0700c3fd46746375f45752366 Mon Sep 17 00:00:00 2001 From: ucwong Date: Fri, 21 Oct 2022 09:29:08 +0800 Subject: [PATCH 1/2] bootnode fix --- cmd/bootnode/main.go | 4 +--- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/CortexFoundation/torrentfs/doc.go | 8 ++++---- vendor/github.com/CortexFoundation/torrentfs/fs.go | 9 ++------- vendor/github.com/CortexFoundation/torrentfs/peer.go | 3 +-- vendor/modules.txt | 2 +- 7 files changed, 12 insertions(+), 20 deletions(-) diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go index 740e1d8d86..c547d733c7 100644 --- a/cmd/bootnode/main.go +++ b/cmd/bootnode/main.go @@ -49,7 +49,6 @@ func main() { netrestrict = flag.String("netrestrict", "", "restrict network communication to the given IP networks (CIDR masks)") runv5 = flag.Bool("v5", false, "run a v5 topic discovery bootnode") verbosity = flag.Int("verbosity", int(log.LvlInfo), "log verbosity (0-9)") - vmodule = flag.String("vmodule", "", "log verbosity pattern") nodeKey *ecdsa.PrivateKey err error @@ -58,7 +57,6 @@ func main() { glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) glogger.Verbosity(log.Lvl(*verbosity)) - glogger.Vmodule(*vmodule) log.Root().SetHandler(glogger) natm, err := nat.Parse(*natdesc) @@ -116,7 +114,7 @@ func main() { realaddr := conn.LocalAddr().(*net.UDPAddr) if natm != nil { if !realaddr.IP.IsLoopback() { - go nat.Map(natm, nil, "udp", realaddr.Port, realaddr.Port, "CortexFoundation discovery") + go nat.Map(natm, nil, "udp", realaddr.Port, realaddr.Port, "Cortex discovery") } if ext, err := natm.ExternalIP(); err == nil { realaddr = &net.UDPAddr{IP: ext, Port: realaddr.Port} diff --git a/go.mod b/go.mod index e6f3664562..aa834add9f 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1 github.com/CortexFoundation/inference v1.0.2-0.20220421072809-9c87efb8a557 github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 - github.com/CortexFoundation/torrentfs v1.0.33-0.20221020175559-927dc9538190 + github.com/CortexFoundation/torrentfs v1.0.33-0.20221021001537-641d75775acb github.com/VictoriaMetrics/fastcache v1.12.0 github.com/arsham/figurine v1.2.0 github.com/aws/aws-sdk-go-v2 v1.16.16 diff --git a/go.sum b/go.sum index 2a37478f89..66721a08a1 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66/go.mod h1: github.com/CortexFoundation/torrentfs v1.0.13-0.20200623060705-ce027f43f2f8/go.mod h1:Ma+tGhPPvz4CEZHaqEJQMOEGOfHeQBiAoNd1zyc/w3Q= github.com/CortexFoundation/torrentfs v1.0.14-0.20200703071639-3fcabcabf274/go.mod h1:qnb3YlIJmuetVBtC6Lsejr0Xru+1DNmDCdTqnwy7lhk= github.com/CortexFoundation/torrentfs v1.0.20-0.20200810031954-d36d26f82fcc/go.mod h1:N5BsicP5ynjXIi/Npl/SRzlJ630n1PJV2sRj0Z0t2HA= -github.com/CortexFoundation/torrentfs v1.0.33-0.20221020175559-927dc9538190 h1:jx9TRIG60umYuM55D4dOa2KinqigL0NRcPaiWqrQkdo= -github.com/CortexFoundation/torrentfs v1.0.33-0.20221020175559-927dc9538190/go.mod h1:NPdS3bCOzmMYsrJqB+ib4PYzCvEmJiDJ7KiiIffLbSg= +github.com/CortexFoundation/torrentfs v1.0.33-0.20221021001537-641d75775acb h1:dEhTSUsK9BnV9T+sPGurS1+cWnuLiEYVPs9x0Z090vw= +github.com/CortexFoundation/torrentfs v1.0.33-0.20221021001537-641d75775acb/go.mod h1:NPdS3bCOzmMYsrJqB+ib4PYzCvEmJiDJ7KiiIffLbSg= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= github.com/HdrHistogram/hdrhistogram-go v1.1.0 h1:6dpdDPTRoo78HxAJ6T1HfMiKSnqhgRRqzCuPshRkQ7I= diff --git a/vendor/github.com/CortexFoundation/torrentfs/doc.go b/vendor/github.com/CortexFoundation/torrentfs/doc.go index b1fb9fb96b..e512ff0daa 100644 --- a/vendor/github.com/CortexFoundation/torrentfs/doc.go +++ b/vendor/github.com/CortexFoundation/torrentfs/doc.go @@ -28,11 +28,11 @@ const ( DefaultMaxMessageSize = uint32(1024) - statusCode = 0 - queryCode = 1 - msgCode = 2 + statusCode = iota + queryCode + msgCode - peerStateCycle = time.Second * 60 + peerStateCycle = time.Second * 300 expirationCycle = time.Second transmissionCycle = 300 * time.Millisecond diff --git a/vendor/github.com/CortexFoundation/torrentfs/fs.go b/vendor/github.com/CortexFoundation/torrentfs/fs.go index 1f4c2f3938..b7f7a9df27 100644 --- a/vendor/github.com/CortexFoundation/torrentfs/fs.go +++ b/vendor/github.com/CortexFoundation/torrentfs/fs.go @@ -326,12 +326,7 @@ func (tfs *TorrentFS) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error { return err } } - tfs.nasCounter++ - } else if info.Size == 0 { - // TODO - } else { - // TODO } } case msgCode: @@ -341,7 +336,7 @@ func (tfs *TorrentFS) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error { log.Warn("failed to decode msg, peer will be disconnected", "peer", p.peer.ID(), "err", err) return errors.New("invalid msg") } - log.Warn("Nas 4 testing", "msgCode", msgCode, "package", info.Desc) + log.Warn("Nas msg testing", "code", msgCode, "desc", info.Desc) } default: log.Warn("Encounter package code", "code", packet.Code) @@ -461,7 +456,7 @@ func (fs *TorrentFS) query(ih string, rawSize uint64) bool { return false } - if _, suc := fs.msg.Get(ih); suc == nil { + if _, err := fs.msg.Get(ih); err == nil { return false } diff --git a/vendor/github.com/CortexFoundation/torrentfs/peer.go b/vendor/github.com/CortexFoundation/torrentfs/peer.go index c1bcb3d59c..71b04d21ee 100644 --- a/vendor/github.com/CortexFoundation/torrentfs/peer.go +++ b/vendor/github.com/CortexFoundation/torrentfs/peer.go @@ -111,7 +111,6 @@ func (peer *Peer) update() { select { case <-expire.C: peer.expire() - //case query := <-peer.host.queryChan: case <-transmit.C: if err := peer.broadcast(); err != nil { log.Trace("transmit broadcast failed", "reason", err, "peer", peer.ID()) @@ -163,7 +162,7 @@ func (peer *Peer) marked(hash string) bool { func (peer *Peer) broadcast() error { for _, k := range peer.host.Envelopes().Keys() { - if v, ok := peer.host.Envelopes().Get(k.Interface().(string)); ok == nil { + if v, err := peer.host.Envelopes().Get(k.Interface().(string)); err == nil { if !peer.marked(k.Interface().(string)) { query := Query{ Hash: k.Interface().(string), diff --git a/vendor/modules.txt b/vendor/modules.txt index 588864cab0..303da52fdd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -48,7 +48,7 @@ github.com/CortexFoundation/merkletree # github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 ## explicit; go 1.16 github.com/CortexFoundation/statik -# github.com/CortexFoundation/torrentfs v1.0.33-0.20221020175559-927dc9538190 +# github.com/CortexFoundation/torrentfs v1.0.33-0.20221021001537-641d75775acb ## explicit; go 1.19 github.com/CortexFoundation/torrentfs github.com/CortexFoundation/torrentfs/compress From acc4eaa23202517dd1a8893c90c7751b0397ee48 Mon Sep 17 00:00:00 2001 From: ucwong Date: Fri, 21 Oct 2022 15:11:05 +0800 Subject: [PATCH 2/2] fix --- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/CortexFoundation/torrentfs/doc.go | 6 +++--- vendor/modules.txt | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index aa834add9f..9a5aeece06 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.4.1 github.com/CortexFoundation/inference v1.0.2-0.20220421072809-9c87efb8a557 github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 - github.com/CortexFoundation/torrentfs v1.0.33-0.20221021001537-641d75775acb + github.com/CortexFoundation/torrentfs v1.0.33-0.20221021070845-0196b03bf907 github.com/VictoriaMetrics/fastcache v1.12.0 github.com/arsham/figurine v1.2.0 github.com/aws/aws-sdk-go-v2 v1.16.16 diff --git a/go.sum b/go.sum index 66721a08a1..e731be5035 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66/go.mod h1: github.com/CortexFoundation/torrentfs v1.0.13-0.20200623060705-ce027f43f2f8/go.mod h1:Ma+tGhPPvz4CEZHaqEJQMOEGOfHeQBiAoNd1zyc/w3Q= github.com/CortexFoundation/torrentfs v1.0.14-0.20200703071639-3fcabcabf274/go.mod h1:qnb3YlIJmuetVBtC6Lsejr0Xru+1DNmDCdTqnwy7lhk= github.com/CortexFoundation/torrentfs v1.0.20-0.20200810031954-d36d26f82fcc/go.mod h1:N5BsicP5ynjXIi/Npl/SRzlJ630n1PJV2sRj0Z0t2HA= -github.com/CortexFoundation/torrentfs v1.0.33-0.20221021001537-641d75775acb h1:dEhTSUsK9BnV9T+sPGurS1+cWnuLiEYVPs9x0Z090vw= -github.com/CortexFoundation/torrentfs v1.0.33-0.20221021001537-641d75775acb/go.mod h1:NPdS3bCOzmMYsrJqB+ib4PYzCvEmJiDJ7KiiIffLbSg= +github.com/CortexFoundation/torrentfs v1.0.33-0.20221021070845-0196b03bf907 h1:H/AtXPQ1ulsVeFi74MzewUlmZl3OIMlB60TOck3I6wk= +github.com/CortexFoundation/torrentfs v1.0.33-0.20221021070845-0196b03bf907/go.mod h1:NPdS3bCOzmMYsrJqB+ib4PYzCvEmJiDJ7KiiIffLbSg= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= github.com/HdrHistogram/hdrhistogram-go v1.1.0 h1:6dpdDPTRoo78HxAJ6T1HfMiKSnqhgRRqzCuPshRkQ7I= diff --git a/vendor/github.com/CortexFoundation/torrentfs/doc.go b/vendor/github.com/CortexFoundation/torrentfs/doc.go index e512ff0daa..cc39aaf420 100644 --- a/vendor/github.com/CortexFoundation/torrentfs/doc.go +++ b/vendor/github.com/CortexFoundation/torrentfs/doc.go @@ -28,9 +28,9 @@ const ( DefaultMaxMessageSize = uint32(1024) - statusCode = iota - queryCode - msgCode + statusCode = 0 + queryCode = 1 + msgCode = 2 peerStateCycle = time.Second * 300 diff --git a/vendor/modules.txt b/vendor/modules.txt index 303da52fdd..cf4c405ed5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -48,7 +48,7 @@ github.com/CortexFoundation/merkletree # github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 ## explicit; go 1.16 github.com/CortexFoundation/statik -# github.com/CortexFoundation/torrentfs v1.0.33-0.20221021001537-641d75775acb +# github.com/CortexFoundation/torrentfs v1.0.33-0.20221021070845-0196b03bf907 ## explicit; go 1.19 github.com/CortexFoundation/torrentfs github.com/CortexFoundation/torrentfs/compress