Пример #1
0
func (p *Peer) fillQueue() {
	for {
		start, end := p.GetLedgerRange()
		r := &data.LedgerRange{
			Start: start,
			End:   end,
			Max:   20,
		}
		work := p.sync.Missing(r)
		glog.V(1).Infof("%s:Queueing %d-%d %+v", p.String(), start, end, work.MissingLedgers)
		if len(work.MissingLedgers) < 2 {
			time.Sleep(5 * time.Second)
			continue
		}
		for _, ledger := range work.MissingLedgers {
			p.synchronous <- protocol.NewGetLedger(ledger)
		}
	}
}
Пример #2
0
func (p *Peer) fillQueue(l *ledger.Manager) {
	for {
		start, end := p.GetLedgerRange()
		request := &ledger.MissingLedgers{
			Request: &data.LedgerRange{
				Start: start,
				End:   end,
				Max:   20,
			},
			Response: make(chan data.LedgerSlice),
		}
		l.Missing <- request
		missing := <-request.Response
		glog.V(1).Infof("%s:Queueing %d-%d %+v", p.String(), start, end, missing)
		if len(missing) < 2 {
			time.Sleep(5 * time.Second)
			continue
		}
		for _, ledger := range missing {
			p.synchronous <- protocol.NewGetLedger(ledger)
		}
	}
}