diff --git a/go.mod b/go.mod index 2e7d6a639e..b3c41d5137 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.2 github.com/CortexFoundation/inference v1.0.2-0.20230307032835-9197d586a4e8 github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 - github.com/CortexFoundation/torrentfs v1.0.67-0.20240616121104-faf07a077bcb + github.com/CortexFoundation/torrentfs v1.0.67-0.20240617131343-521cdf7868e0 github.com/VictoriaMetrics/fastcache v1.12.2 github.com/arsham/figurine v1.3.0 github.com/aws/aws-sdk-go-v2 v1.27.2 @@ -131,7 +131,7 @@ require ( github.com/charmbracelet/x/term v0.1.1 // indirect github.com/charmbracelet/x/windows v0.1.2 // indirect github.com/cockroachdb/errors v1.11.3 // indirect - github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect + github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect diff --git a/go.sum b/go.sum index a83067b6f3..0b511ad516 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,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.67-0.20240616121104-faf07a077bcb h1:HvyK/Xur0eolLonOdHWEg9aFZJTO/UxzXjEw5b+FnyY= -github.com/CortexFoundation/torrentfs v1.0.67-0.20240616121104-faf07a077bcb/go.mod h1:W2y1wq8+emWbHNDc5Vq8StIgZb9PB5zIYSNyWQdm0oQ= +github.com/CortexFoundation/torrentfs v1.0.67-0.20240617131343-521cdf7868e0 h1:pVbmz8pcQiQI+JyCHIcuBSDp/EAjkBVbyFBmDmrDboo= +github.com/CortexFoundation/torrentfs v1.0.67-0.20240617131343-521cdf7868e0/go.mod h1:W2y1wq8+emWbHNDc5Vq8StIgZb9PB5zIYSNyWQdm0oQ= github.com/CortexFoundation/wormhole v0.0.2-0.20240503144741-71d4d22383f0 h1:pePXS+/6usgcC1G2Ma3pX7fJwoRcgLPyu5SLawrTszc= github.com/CortexFoundation/wormhole v0.0.2-0.20240503144741-71d4d22383f0/go.mod h1:ipzmPabDgzYKUbXkGVe2gTkBEp+MsDx6pXGiuYzmP6s= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= @@ -363,8 +363,8 @@ github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaY github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= +github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a h1:f52TdbU4D5nozMAhO9TvTJ2ZMCXtN4VIAmfrrZ0JXQ4= +github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= diff --git a/trie/secure_trie.go b/trie/secure_trie.go index aca01cc2d4..2f40f9bc42 100644 --- a/trie/secure_trie.go +++ b/trie/secure_trie.go @@ -240,7 +240,7 @@ func (t *StateTrie) Commit(onleaf LeafCallback) (root common.Hash, err error) { // Write all the pre-images to the actual disk database if len(t.getSecKeyCache()) > 0 { if t.preimages != nil { - preimages := make(map[common.Hash][]byte) + preimages := make(map[common.Hash][]byte, len(t.secKeyCache)) for hk, key := range t.secKeyCache { preimages[common.BytesToHash([]byte(hk))] = key } diff --git a/vendor/github.com/CortexFoundation/torrentfs/backend/caffe/t.go b/vendor/github.com/CortexFoundation/torrentfs/backend/caffe/t.go index 075ac7d6fc..a8cbcdd80c 100644 --- a/vendor/github.com/CortexFoundation/torrentfs/backend/caffe/t.go +++ b/vendor/github.com/CortexFoundation/torrentfs/backend/caffe/t.go @@ -46,6 +46,8 @@ func (t *Torrent) SpecNoTrackers() *torrent.TorrentSpec { } func (t *Torrent) Dirty() bool { + //t.RLock() + //defer t.RUnlock() return t.dirty.Load() } @@ -127,20 +129,10 @@ func (t *Torrent) BytesRequested() int64 { func (t *Torrent) SetBytesRequested(bytesRequested int64) { t.lock.Lock() defer t.lock.Unlock() - // Store the torrent information in a variable for reuse - info := t.Info() - - // Check if the torrent has associated information - if info != nil { - // Limit the requested bytes to the total length of the torrent - if bytesRequested > t.Length() { - bytesRequested = t.Length() - } - } - if bytesRequested > t.bytesRequested.Load() || t.bytesRequested.Load() > t.Length() { + if bytesRequested > t.bytesRequested.Load() { t.dirty.Store(true) - log.Debug("Request bytes updated", "ih", t.InfoHash(), "request", bytesRequested, "status", t.Status()) + log.Debug("Request bytes updated", "ih", t.InfoHash(), "request", bytesRequested, "origin", t.bytesRequested.Load(), "len", t.Torrent.Length(), "status", t.Status(), "dirty", t.dirty.Load()) t.bytesRequested.Store(bytesRequested) } } diff --git a/vendor/github.com/CortexFoundation/torrentfs/backend/handler.go b/vendor/github.com/CortexFoundation/torrentfs/backend/handler.go index 4f1417f96d..9fcd9a6834 100644 --- a/vendor/github.com/CortexFoundation/torrentfs/backend/handler.go +++ b/vendor/github.com/CortexFoundation/torrentfs/backend/handler.go @@ -972,6 +972,11 @@ func (tm *TorrentManager) mainLoop() { continue } + if tm.mode == params.LAZY { + if meta.Request() == 0 { + continue + } + } if t := tm.addInfoHash(meta.InfoHash(), int64(meta.Request())); t == nil { log.Error("Seed [create] failed", "ih", meta.InfoHash(), "request", meta.Request()) } else { @@ -1028,6 +1033,7 @@ func (tm *TorrentManager) pendingLoop() { } if m, ok := ev.Data.(pendingEvent); ok { t := m.T + log.Debug("Searching", "ih", t.InfoHash()) if t.Torrent.Info() != nil { tm.meta(t) continue @@ -1084,7 +1090,8 @@ func (tm *TorrentManager) meta(t *caffe.Torrent) error { return err } - if params.IsGood(t.InfoHash()) || tm.mode == params.FULL || t.BytesRequested() > t.Length() { + log.Debug("Meta found", "ih", t.InfoHash(), "len", t.Length()) + if params.IsGood(t.InfoHash()) || tm.mode == params.FULL { t.SetBytesRequested(t.Length()) // request bytes fix after meta information got } @@ -1192,15 +1199,6 @@ func (tm *TorrentManager) activeLoop() { }(t.InfoHash(), n) } case <-timer_1.C: - if tm.fc != nil { - log.Debug("Cache status", "total", common.StorageSize(tm.fc.FileSize()), "itms", tm.fc.Size()) - if tm.mode == params.LAZY { - for _, itm := range tm.fc.MostAccessed(4) { - log.Debug("Cache status", "key", itm.Key(), "acc", itm.AccessCount, "dur", common.PrettyDuration(itm.Dur())) - } - } - } - //if tm.dur() > 0 { //stopped := int32(tm.torrents.Len()) - tm.seeds.Load() - tm.actives.Load() - tm.pends.Load() log.Info("Fs status", "pending", tm.pends.Load(), "downloading", tm.actives.Load(), "seeding", tm.seeds.Load(), "stopping", tm.stops.Load(), "all", tm.torrents.Len(), "recovery", tm.recovery.Load(), "metrics", common.PrettyDuration(tm.Updates)) //, "total", common.StorageSize(tm.total()), "cost", common.PrettyDuration(time.Duration(tm.dur())), "speed", common.StorageSize(float64(tm.total()*1000*1000*1000)/float64(tm.dur())).String()+"/s") diff --git a/vendor/modules.txt b/vendor/modules.txt index 54278a16e6..73e046af7e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -61,7 +61,7 @@ github.com/CortexFoundation/robot/backend # github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 ## explicit; go 1.16 github.com/CortexFoundation/statik -# github.com/CortexFoundation/torrentfs v1.0.67-0.20240616121104-faf07a077bcb +# github.com/CortexFoundation/torrentfs v1.0.67-0.20240617131343-521cdf7868e0 ## explicit; go 1.22 github.com/CortexFoundation/torrentfs github.com/CortexFoundation/torrentfs/backend @@ -385,7 +385,7 @@ github.com/cockroachdb/errors/secondary github.com/cockroachdb/errors/stdstrings github.com/cockroachdb/errors/telemetrykeys github.com/cockroachdb/errors/withstack -# github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce +# github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a ## explicit; go 1.20 github.com/cockroachdb/fifo # github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b