@@ -27,9 +27,9 @@ type dialResponse struct {
2727}
2828
2929type pendRequest struct {
30- req dialRequest // the original request
31- err * DialError // dial error accumulator
32- addrs map [ma. Multiaddr ]struct {} // pending addr dials
30+ req dialRequest // the original request
31+ err * DialError // dial error accumulator
32+ addrs map [string ]struct {} // pending address to dial. The key is a multiaddr
3333}
3434
3535type addrDial struct {
@@ -47,7 +47,7 @@ type dialWorker struct {
4747 reqch <- chan dialRequest
4848 reqno int
4949 requests map [int ]* pendRequest
50- pending map [ma. Multiaddr ]* addrDial
50+ pending map [string ]* addrDial // pending addresses to dial. The key is a multiaddr
5151 resch chan dialResult
5252
5353 connected bool // true when a connection has been successfully established
@@ -67,7 +67,7 @@ func newDialWorker(s *Swarm, p peer.ID, reqch <-chan dialRequest) *dialWorker {
6767 peer : p ,
6868 reqch : reqch ,
6969 requests : make (map [int ]* pendRequest ),
70- pending : make (map [ma. Multiaddr ]* addrDial ),
70+ pending : make (map [string ]* addrDial ),
7171 resch : make (chan dialResult ),
7272 }
7373}
@@ -109,10 +109,10 @@ loop:
109109 pr := & pendRequest {
110110 req : req ,
111111 err : & DialError {Peer : w .peer },
112- addrs : make (map [ma. Multiaddr ]struct {}),
112+ addrs : make (map [string ]struct {}),
113113 }
114114 for _ , a := range addrs {
115- pr .addrs [a ] = struct {}{}
115+ pr .addrs [string ( a . Bytes ()) ] = struct {}{}
116116 }
117117
118118 // check if any of the addrs has been successfully dialed and accumulate
@@ -121,7 +121,7 @@ loop:
121121 var tojoin []* addrDial
122122
123123 for _ , a := range addrs {
124- ad , ok := w .pending [a ]
124+ ad , ok := w .pending [string ( a . Bytes ()) ]
125125 if ! ok {
126126 todial = append (todial , a )
127127 continue
@@ -136,7 +136,7 @@ loop:
136136 if ad .err != nil {
137137 // dial to this addr errored, accumulate the error
138138 pr .err .recordErr (a , ad .err )
139- delete (pr .addrs , a )
139+ delete (pr .addrs , string ( a . Bytes ()) )
140140 continue
141141 }
142142
@@ -167,7 +167,7 @@ loop:
167167
168168 if len (todial ) > 0 {
169169 for _ , a := range todial {
170- w .pending [a ] = & addrDial {addr : a , ctx : req .ctx , requests : []int {w .reqno }}
170+ w .pending [string ( a . Bytes ()) ] = & addrDial {addr : a , ctx : req .ctx , requests : []int {w .reqno }}
171171 }
172172
173173 w .nextDial = append (w .nextDial , todial ... )
@@ -180,7 +180,7 @@ loop:
180180 case <- w .triggerDial :
181181 for _ , addr := range w .nextDial {
182182 // spawn the dial
183- ad := w .pending [addr ]
183+ ad := w .pending [string ( addr . Bytes ()) ]
184184 err := w .s .dialNextAddr (ad .ctx , w .peer , addr , w .resch )
185185 if err != nil {
186186 w .dispatchError (ad , err )
@@ -195,7 +195,7 @@ loop:
195195 w .connected = true
196196 }
197197
198- ad := w .pending [res .Addr ]
198+ ad := w .pending [string ( res .Addr . Bytes ()) ]
199199
200200 if res .Conn != nil {
201201 // we got a connection, add it to the swarm
@@ -250,7 +250,7 @@ func (w *dialWorker) dispatchError(ad *addrDial, err error) {
250250 // accumulate the error
251251 pr .err .recordErr (ad .addr , err )
252252
253- delete (pr .addrs , ad .addr )
253+ delete (pr .addrs , string ( ad .addr . Bytes ()) )
254254 if len (pr .addrs ) == 0 {
255255 // all addrs have erred, dispatch dial error
256256 // but first do a last one check in case an acceptable connection has landed from
@@ -274,7 +274,7 @@ func (w *dialWorker) dispatchError(ad *addrDial, err error) {
274274 // it is also necessary to preserve consisent behaviour with the old dialer -- TestDialBackoff
275275 // regresses without this.
276276 if err == ErrDialBackoff {
277- delete (w .pending , ad .addr )
277+ delete (w .pending , string ( ad .addr . Bytes ()) )
278278 }
279279}
280280
0 commit comments