@@ -82,7 +82,7 @@ type Monitor struct {
82
82
//portLock sync.Mutex
83
83
//portsWg sync.WaitGroup
84
84
85
- taskCh chan * Block
85
+ // taskCh chan *Block
86
86
newTaskHook func (* Block )
87
87
blockCache * lru.Cache
88
88
healthPeers * lru.Cache
@@ -121,7 +121,7 @@ func NewMonitor(flag *Config) (m *Monitor, e error) {
121
121
terminated : 0 ,
122
122
lastNumber : uint64 (0 ),
123
123
dirty : false ,
124
- taskCh : make (chan * Block , batch * 2 ),
124
+ // taskCh: make(chan *Block, batch*2),
125
125
}
126
126
m .blockCache , _ = lru .New (6 )
127
127
m .healthPeers , _ = lru .New (50 )
@@ -175,7 +175,7 @@ func NewMonitor(flag *Config) (m *Monitor, e error) {
175
175
return m , e
176
176
}
177
177
178
- func (m * Monitor ) taskLoop () {
178
+ /* func (m *Monitor) taskLoop() {
179
179
defer m.wg.Done()
180
180
for {
181
181
select {
@@ -186,13 +186,14 @@ func (m *Monitor) taskLoop() {
186
186
187
187
if err := m.deal(task); err != nil {
188
188
log.Warn("Block dealing failed", "err", err)
189
+ continue
189
190
}
190
191
case <-m.exitCh:
191
192
log.Info("Monitor task channel closed")
192
193
return
193
194
}
194
195
}
195
- }
196
+ }*/
196
197
197
198
// SetConnection method builds connection to remote or local communicator.
198
199
func SetConnection (clientURI string ) (* rpc.Client , error ) {
@@ -531,7 +532,8 @@ func (m *Monitor) parseBlockTorrentInfo(b *Block, flowCtrl bool) error {
531
532
func (m * Monitor ) Stop () {
532
533
log .Info ("Torrent listener closing" )
533
534
atomic .StoreInt32 (& (m .terminated ), 1 )
534
- close (m .exitCh )
535
+ //close(m.exitCh)
536
+ //m.wg.Wait()
535
537
m .wg .Wait ()
536
538
/*m.wg.Add(1)
537
539
m.closeOnce.Do(func() {
@@ -630,8 +632,8 @@ func (m *Monitor) startWork() error {
630
632
//}
631
633
632
634
//log.Info("Torrent fs validation passed")
633
- m .wg .Add (1 )
634
- go m .taskLoop ()
635
+ // m.wg.Add(1)
636
+ // go m.taskLoop()
635
637
m .wg .Add (1 )
636
638
go m .listenLatestBlock ()
637
639
m .init ()
@@ -895,6 +897,7 @@ func (m *Monitor) syncLastBlock() uint64 {
895
897
if atomic .LoadInt32 (& (m .terminated )) == 1 {
896
898
log .Warn ("Torrent scan terminated" , "number" , i )
897
899
maxNumber = i - 1
900
+ close (m .exitCh )
898
901
break
899
902
}
900
903
@@ -903,7 +906,8 @@ func (m *Monitor) syncLastBlock() uint64 {
903
906
log .Error ("Sync old block failed" , "number" , i , "error" , rpcErr )
904
907
return 0
905
908
}
906
- m .taskCh <- rpcBlock
909
+ //m.taskCh <- rpcBlock
910
+ m .deal (rpcBlock )
907
911
}
908
912
elapsed := time .Duration (mclock .Now ()) - time .Duration (start )
909
913
m .lastNumber = maxNumber
0 commit comments