Skip to content

Commit

Permalink
Merge pull request #76 from CortexFoundation/dev
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
ucwong authored Jul 27, 2020
2 parents de87fde + 8c4cf77 commit 97d6e83
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func NewMonitor(flag *Config, cache, compress, listen bool) (*Monitor, error) {
scope: uint64(math.Min(float64(runtime.NumCPU()*4), float64(8))),
currentNumber: uint64(0),
//taskCh: make(chan *types.Block, batch),
start: mclock.Now(),
//start: mclock.Now(),
}
m.blockCache, _ = lru.New(delay)
m.sizeCache, _ = lru.New(batch)
Expand Down Expand Up @@ -354,8 +354,9 @@ func (m *Monitor) parseFileMeta(tx *types.Transaction, meta *types.FileMeta, b *
if update && op == 1 {
log.Debug("Create new file", "ih", meta.InfoHash, "op", op)

m.fs.AddTorrent(meta.InfoHash.HexString(), 0)
m.dl.Search(context.Background(), meta.InfoHash.HexString(), 0)
if u, err := m.fs.AddTorrent(meta.InfoHash.HexString(), 0); u && err == nil {
m.dl.Search(context.Background(), meta.InfoHash.HexString(), 0)
}
//m.dl.UpdateTorrent(context.Background(), types.FlowControlMeta{
// InfoHash: meta.InfoHash,
// BytesRequested: 0,
Expand Down Expand Up @@ -416,8 +417,9 @@ func (m *Monitor) parseBlockTorrentInfo(b *types.Block) (bool, error) {
} else {
log.Debug("Data processing ...", "ih", file.Meta.InfoHash, "addr", (*tx.Recipient).String(), "remain", common.StorageSize(remainingSize), "request", common.StorageSize(bytesRequested), "raw", common.StorageSize(file.Meta.RawSize), "number", b.Number)
}
m.fs.AddTorrent(file.Meta.InfoHash.HexString(), bytesRequested)
m.dl.Search(context.Background(), file.Meta.InfoHash.HexString(), bytesRequested)
if u, err := m.fs.AddTorrent(file.Meta.InfoHash.HexString(), bytesRequested); u && err == nil {
m.dl.Search(context.Background(), file.Meta.InfoHash.HexString(), bytesRequested)
}
//m.dl.UpdateTorrent(context.Background(), types.FlowControlMeta{
// InfoHash: file.Meta.InfoHash,
// BytesRequested: bytesRequested,
Expand Down Expand Up @@ -649,6 +651,9 @@ func (m *Monitor) syncLastBlock() uint64 {
if maxNumber < minNumber {
return 0
}
if m.start == 0 {
m.start = mclock.Now()
}
//start := mclock.Now()
for i := minNumber; i <= maxNumber; { // i++ {
if atomic.LoadInt32(&(m.terminated)) == 1 {
Expand Down

0 comments on commit 97d6e83

Please sign in to comment.