Skip to content

Commit

Permalink
Merge pull request #435 from lochjin/main
Browse files Browse the repository at this point in the history
BUG:mempool
  • Loading branch information
dindinw authored May 19, 2023
2 parents 0b53c15 + 32ec499 commit 15d9465
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions p2p/rebroadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ func (r *Rebroadcast) Start() {

log.Info("Starting Rebroadcast")

r.wg.Add(1)
r.wg.Add(2)
go r.handler()
go r.mempoolHandler()
}

func (r *Rebroadcast) Stop() error {
Expand All @@ -66,9 +67,23 @@ func (r *Rebroadcast) Stop() error {

}

func (r *Rebroadcast) mempoolHandler() {
timer := time.NewTimer(params.ActiveNetParams.TargetTimePerBlock)
out:
for {
select {
case <-timer.C:
r.onRegainMempool()
case <-r.quit:
break out
}
}
timer.Stop()
r.wg.Done()
}

func (r *Rebroadcast) handler() {
timer := time.NewTimer(params.ActiveNetParams.TargetTimePerBlock)
timerMP := time.NewTimer(params.ActiveNetParams.TargetTimePerBlock)
pendingInvs := make(map[hash.Hash]interface{})

out:
Expand Down Expand Up @@ -110,9 +125,6 @@ out:
timer.Reset(time.Duration(rt))

r.s.sy.Peers().UpdateBroadcasts()

case <-timerMP.C:
r.onRegainMempool()
case <-r.quit:
break out
}
Expand Down

0 comments on commit 15d9465

Please sign in to comment.