Add Peer.mustRequest

This commit is contained in:
Matt Joiner 2021-10-26 15:03:04 +11:00
parent 98957b6e8e
commit 31985f1ea0
2 changed files with 9 additions and 4 deletions

View File

@ -585,6 +585,14 @@ func (cn *Peer) shouldRequest(r RequestIndex) error {
return nil
}
func (cn *Peer) mustRequest(r RequestIndex) bool {
more, err := cn.request(r)
if err != nil {
panic(err)
}
return more
}
func (cn *Peer) request(r RequestIndex) (more bool, err error) {
if err := cn.shouldRequest(r); err != nil {
panic(err)

View File

@ -304,10 +304,7 @@ func (p *Peer) applyRequestState(next requestState) bool {
//)
break
}
more, err = p.request(req)
if err != nil {
panic(err)
}
more = p.mustRequest(req)
if !more {
break
}