Skip to content

Commit

Permalink
Merge pull request #231 from CortexFoundation/dev
Browse files Browse the repository at this point in the history
Dev->Master
  • Loading branch information
ucwong authored Nov 18, 2019
2 parents 9ee29f3 + 9fd8a37 commit 954de9f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion torrentfs/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const (
type TorrentManagerAPI interface {
Start() error
Close() error
RemoveTorrent(metainfo.Hash) error
//RemoveTorrent(metainfo.Hash) error
UpdateTorrent(interface{}) error
UpdateDynamicTrackers(trackers []string)
GetTorrent(ih metainfo.Hash) *Torrent
Expand Down
2 changes: 1 addition & 1 deletion torrentfs/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func NewFileStorage(config *Config) (*FileStorage, error) {
if dbErr != nil {
return nil, dbErr
}
db.NoSync = true
//db.NoSync = true

fs := &FileStorage{
// filesInfoHash: make(map[metainfo.Hash]*FileInfo),
Expand Down
26 changes: 13 additions & 13 deletions torrentfs/torrentClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

const (
removeTorrentChanBuffer = 1
//removeTorrentChanBuffer = 1
updateTorrentChanBuffer = 2048

torrentPending = iota //2
Expand Down Expand Up @@ -298,8 +298,8 @@ type TorrentManager struct {
DataDir string
TmpDataDir string
closeAll chan struct{}
removeTorrent chan metainfo.Hash
updateTorrent chan interface{}
//removeTorrent chan metainfo.Hash
updateTorrent chan interface{}
//mu sync.Mutex
lock sync.RWMutex
wg sync.WaitGroup
Expand Down Expand Up @@ -364,10 +364,10 @@ func (tm *TorrentManager) dropAll() {
}
}

func (tm *TorrentManager) RemoveTorrent(input metainfo.Hash) error {
tm.removeTorrent <- input
return nil
}
//func (tm *TorrentManager) RemoveTorrent(input metainfo.Hash) error {
// tm.removeTorrent <- input
// return nil
//}

func (tm *TorrentManager) UpdateTorrent(input interface{}) error {
//go func() {tm.updateTorrent <- input}()
Expand Down Expand Up @@ -582,7 +582,7 @@ func (tm *TorrentManager) UpdateInfoHash(ih metainfo.Hash, BytesRequested int64)
}

// DropInfoHash ...
func (tm *TorrentManager) DropInfoHash(ih metainfo.Hash) bool {
/*func (tm *TorrentManager) DropInfoHash(ih metainfo.Hash) bool {
if t := tm.GetTorrent(ih); t != nil {
t.Torrent.Drop()
tm.lock.Lock()
Expand All @@ -591,7 +591,7 @@ func (tm *TorrentManager) DropInfoHash(ih metainfo.Hash) bool {
return true
}
return false
}
}*/

//var CurrentTorrentManager *TorrentManager = nil

Expand Down Expand Up @@ -662,8 +662,8 @@ func NewTorrentManager(config *Config) *TorrentManager {
TmpDataDir: tmpFilePath,
boostFetcher: NewBoostDataFetcher(config.BoostNodes),
closeAll: make(chan struct{}),
removeTorrent: make(chan metainfo.Hash, removeTorrentChanBuffer),
updateTorrent: make(chan interface{}, updateTorrentChanBuffer),
//removeTorrent: make(chan metainfo.Hash, removeTorrentChanBuffer),
updateTorrent: make(chan interface{}, updateTorrentChanBuffer),
//updateTorrent: make(chan interface{}),
}

Expand Down Expand Up @@ -697,8 +697,8 @@ func (tm *TorrentManager) mainLoop() {
defer tm.wg.Done()
for {
select {
case torrent := <-tm.removeTorrent:
tm.DropInfoHash(torrent)
//case torrent := <-tm.removeTorrent:
// tm.DropInfoHash(torrent)
case msg := <-tm.updateTorrent:
meta := msg.(FlowControlMeta)
if meta.IsCreate {
Expand Down

0 comments on commit 954de9f

Please sign in to comment.