Skip to content

Commit 859d8c4

Browse files
committed
Merge branch 'dev' of github.com:CortexFoundation/CortexTheseus into dev
2 parents 7536c90 + d9fcc93 commit 859d8c4

File tree

5 files changed

+36
-38
lines changed

5 files changed

+36
-38
lines changed

inference/synapse/local_infer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ func (s *Synapse) inferByInfoHash(modelInfoHash, inputInfoHash string) (res []by
7575

7676
cacheKey := RLPHashString(modelHash + "_" + inputHash)
7777

78-
if _, ok := CvmFixHashes[cacheKey]; ok {
79-
return CvmFixHashes[cacheKey], nil
78+
if hash, ok := CvmFixHashes[cacheKey]; ok {
79+
return hash, nil
8080
}
8181

8282
if v, ok := s.simpleCache.Load(cacheKey); ok && !s.config.IsNotCache {
@@ -191,8 +191,8 @@ func (s *Synapse) Available(infoHash string, rawSize int64) error {
191191
if s.config.IsRemoteInfer {
192192
errRes := s.remoteAvailable(
193193
infoHash,
194-
rawSize,
195-
s.config.InferURI)
194+
rawSize)
195+
//s.config.InferURI)
196196
return errRes
197197
}
198198
if len(infoHash) < 2 || !strings.HasPrefix(infoHash, "0x") {

inference/synapse/remote_infer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ func (s *Synapse) remoteGasByModelHash(modelInfoHash string) (uint64, error) {
3333
return binary.BigEndian.Uint64(retArray), nil
3434
}
3535

36-
func (s *Synapse) remoteAvailable(infoHash string, rawSize int64, uri string) error {
36+
//func (s *Synapse) remoteAvailable(infoHash string, rawSize int64, uri string) error {
37+
func (s *Synapse) remoteAvailable(infoHash string, rawSize int64) error {
3738
inferWork := &inference.AvailableWork{
3839
Type: inference.AVAILABLE_BY_H,
3940
InfoHash: infoHash,
@@ -47,7 +48,7 @@ func (s *Synapse) remoteAvailable(infoHash string, rawSize int64, uri string) er
4748
}
4849
log.Debug("remoteAvailable", "request", string(requestBody))
4950

50-
_, err := s.sendRequest(string(requestBody), uri)
51+
_, err := s.sendRequest(string(requestBody), s.config.InferURI)
5152
return err
5253
}
5354

torrentfs/monitor.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var (
3939
)
4040

4141
const (
42-
defaultTimerInterval = 3
42+
defaultTimerInterval = 2
4343
connTryTimes = 300
4444
connTryInterval = 2
4545
fetchBlockTryTimes = 5
@@ -733,19 +733,13 @@ func (m *Monitor) listenLatestBlock() {
733733

734734
func (m *Monitor) listenPeers() {
735735
defer m.wg.Done()
736-
timer := time.NewTimer(time.Second * 15)
736+
timer := time.NewTimer(time.Second * 300)
737737

738738
for {
739739
select {
740740
case <-timer.C:
741741
m.peers()
742-
if healthPeers.Len() == 0 {
743-
timer.Reset(time.Second * 5)
744-
} else if healthPeers.Len() < 6 {
745-
timer.Reset(time.Second * 60)
746-
} else {
747-
timer.Reset(time.Second * 300)
748-
}
742+
timer.Reset(time.Second * 300)
749743
case <-m.exitCh:
750744
log.Info("Peers listener stopped")
751745
return
@@ -833,7 +827,7 @@ func (m *Monitor) batch_udp_healthy(ip string, ports []string) ([]string, bool)
833827
}
834828

835829
const (
836-
batch = 2048
830+
batch = 4096
837831
)
838832

839833
func (m *Monitor) syncLastBlock() uint64 {

torrentfs/storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func NewFileStorage(config *Config) (*FileStorage, error) {
9191
if dbErr != nil {
9292
return nil, dbErr
9393
}
94-
//db.NoSync = true
94+
db.NoSync = true
9595

9696
fs := &FileStorage{
9797
// filesInfoHash: make(map[metainfo.Hash]*FileInfo),

torrentfs/torrentClient.go

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"crypto/sha1"
66
//"errors"
77
"fmt"
8-
"github.com/anacrolix/missinggo/slices"
8+
//"github.com/anacrolix/missinggo/slices"
99
"github.com/bradfitz/iter"
1010
"github.com/edsrzf/mmap-go"
1111
"io"
@@ -114,9 +114,9 @@ func (t *Torrent) ReloadFile(files []string, datas [][]byte, tm *TorrentManager)
114114
if err != nil {
115115
return
116116
}
117-
t.Torrent = torrent
118117
<-torrent.GotInfo()
119118
torrent.VerifyData()
119+
t.Torrent = torrent
120120
t.Pause()
121121
}
122122

@@ -148,9 +148,9 @@ func (t *Torrent) ReloadTorrent(data []byte, tm *TorrentManager) {
148148
if err != nil {
149149
return
150150
}
151-
t.Torrent = torrent
152151
<-torrent.GotInfo()
153152
torrent.VerifyData()
153+
t.Torrent = torrent
154154
t.Pause()
155155
}
156156

@@ -354,8 +354,8 @@ func (tm *TorrentManager) Close() error {
354354
}
355355

356356
func (tm *TorrentManager) dropAll() {
357-
tm.lock.Lock()
358-
tm.lock.Unlock()
357+
//tm.lock.Lock()
358+
//tm.lock.Unlock()
359359
defer tm.client.Close()
360360
for _, t := range tm.torrents {
361361
stats := t.Stats()
@@ -495,13 +495,13 @@ func (tm *TorrentManager) AddTorrent(filePath string, BytesRequested int64) *Tor
495495
if err != nil {
496496
return nil
497497
}
498-
var ss []string
499-
slices.MakeInto(&ss, mi.Nodes)
500-
tm.client.AddDHTNodes(ss)
501-
torrent := tm.CreateTorrent(t, BytesRequested, torrentPending, ih)
498+
//var ss []string
499+
//slices.MakeInto(&ss, mi.Nodes)
500+
//tm.client.AddDHTNodes(ss)
502501
<-t.GotInfo()
503502
t.VerifyData()
504-
torrent.SeedInQueue()
503+
torrent := tm.CreateTorrent(t, BytesRequested, torrentPending, ih)
504+
torrent.Pause() //SeedInQueue()
505505
return torrent
506506
} else {
507507
spec.Storage = storage.NewFile(TmpDir)
@@ -512,12 +512,12 @@ func (tm *TorrentManager) AddTorrent(filePath string, BytesRequested int64) *Tor
512512
if err != nil {
513513
return nil
514514
}
515-
var ss []string
516-
slices.MakeInto(&ss, mi.Nodes)
517-
tm.client.AddDHTNodes(ss)
518-
torrent := tm.CreateTorrent(t, BytesRequested, torrentPending, ih)
515+
//var ss []string
516+
//slices.MakeInto(&ss, mi.Nodes)
517+
//tm.client.AddDHTNodes(ss)
519518
<-t.GotInfo()
520519
t.VerifyData()
520+
torrent := tm.CreateTorrent(t, BytesRequested, torrentPending, ih)
521521
torrent.Pause()
522522
return torrent
523523
}
@@ -825,16 +825,18 @@ func (tm *TorrentManager) listenTorrentProgress() {
825825
t.bytesMissing = t.BytesMissing()
826826

827827
if t.Finished() {
828-
os.Symlink(
828+
err := os.Symlink(
829829
path.Join(defaultTmpFilePath, t.InfoHash()),
830830
path.Join(tm.DataDir, t.InfoHash()),
831831
)
832-
delete(tm.activeTorrents, ih)
833-
tm.seedingTorrents[ih] = t
834-
t.Seed()
835-
t.loop = defaultSeedInterval / queryTimeInterval
836-
total_size += uint64(t.bytesCompleted)
837-
current_size += uint64(t.bytesCompleted)
832+
if err == nil {
833+
delete(tm.activeTorrents, ih)
834+
tm.seedingTorrents[ih] = t
835+
t.Seed()
836+
t.loop = defaultSeedInterval / queryTimeInterval
837+
total_size += uint64(t.bytesCompleted)
838+
current_size += uint64(t.bytesCompleted)
839+
}
838840
continue
839841
}
840842

@@ -926,6 +928,7 @@ func (tm *TorrentManager) listenTorrentProgress() {
926928
}
927929
timer.Reset(time.Second * queryTimeInterval)
928930
case <-tm.closeAll:
931+
log.Info("Listen torrent progress closed")
929932
return
930933
}
931934
}

0 commit comments

Comments
 (0)