diff --git a/p2p/handle.go b/p2p/handle.go index 82346c2b5..d8c1bc9ff 100644 --- a/p2p/handle.go +++ b/p2p/handle.go @@ -448,24 +448,17 @@ func (me *Peer) relayOrHandlePeerMessage(relayerId crypto.Hash, msg *PeerMessage if me.relayer == nil { return nil } - data := append([]byte{PeerMessageTypeRelay}, msg.Data...) peer := me.consumers.Get(to) if peer == nil { peer = me.relayers.Get(to) } - if peer != nil { - rk := crypto.Blake3Hash(append(msg.Data, to[:]...)) - rk = crypto.Blake3Hash(append(rk[:], relayerId[:]...)) - success, _ := peer.offer(MsgPriorityNormal, &ChanMsg{rk[:], data}) - if !success { - return fmt.Errorf("peer.offer(%s) consumer timeout", peer.IdForNetwork) - } - return nil + if peer == nil { + peer = me.remoteRelayers.Get(to) } - peer = me.remoteRelayers.Get(to) if peer == nil || peer.IdForNetwork == relayerId { return nil } + data := append([]byte{PeerMessageTypeRelay}, msg.Data...) rk := crypto.Blake3Hash(append(msg.Data, to[:]...)) rk = crypto.Blake3Hash(append(rk[:], relayerId[:]...)) success, _ := peer.offer(MsgPriorityNormal, &ChanMsg{rk[:], data})