@@ -27,9 +27,9 @@ type dialResponse struct {
27
27
}
28
28
29
29
type 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
33
33
}
34
34
35
35
type addrDial struct {
@@ -47,7 +47,7 @@ type dialWorker struct {
47
47
reqch <- chan dialRequest
48
48
reqno int
49
49
requests map [int ]* pendRequest
50
- pending map [ma. Multiaddr ]* addrDial
50
+ pending map [string ]* addrDial // pending addresses to dial. The key is a multiaddr
51
51
resch chan dialResult
52
52
53
53
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 {
67
67
peer : p ,
68
68
reqch : reqch ,
69
69
requests : make (map [int ]* pendRequest ),
70
- pending : make (map [ma. Multiaddr ]* addrDial ),
70
+ pending : make (map [string ]* addrDial ),
71
71
resch : make (chan dialResult ),
72
72
}
73
73
}
@@ -109,10 +109,10 @@ loop:
109
109
pr := & pendRequest {
110
110
req : req ,
111
111
err : & DialError {Peer : w .peer },
112
- addrs : make (map [ma. Multiaddr ]struct {}),
112
+ addrs : make (map [string ]struct {}),
113
113
}
114
114
for _ , a := range addrs {
115
- pr .addrs [a ] = struct {}{}
115
+ pr .addrs [string ( a . Bytes ()) ] = struct {}{}
116
116
}
117
117
118
118
// check if any of the addrs has been successfully dialed and accumulate
@@ -121,7 +121,7 @@ loop:
121
121
var tojoin []* addrDial
122
122
123
123
for _ , a := range addrs {
124
- ad , ok := w .pending [a ]
124
+ ad , ok := w .pending [string ( a . Bytes ()) ]
125
125
if ! ok {
126
126
todial = append (todial , a )
127
127
continue
@@ -136,7 +136,7 @@ loop:
136
136
if ad .err != nil {
137
137
// dial to this addr errored, accumulate the error
138
138
pr .err .recordErr (a , ad .err )
139
- delete (pr .addrs , a )
139
+ delete (pr .addrs , string ( a . Bytes ()) )
140
140
continue
141
141
}
142
142
@@ -167,7 +167,7 @@ loop:
167
167
168
168
if len (todial ) > 0 {
169
169
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 }}
171
171
}
172
172
173
173
w .nextDial = append (w .nextDial , todial ... )
@@ -180,7 +180,7 @@ loop:
180
180
case <- w .triggerDial :
181
181
for _ , addr := range w .nextDial {
182
182
// spawn the dial
183
- ad := w .pending [addr ]
183
+ ad := w .pending [string ( addr . Bytes ()) ]
184
184
err := w .s .dialNextAddr (ad .ctx , w .peer , addr , w .resch )
185
185
if err != nil {
186
186
w .dispatchError (ad , err )
@@ -195,7 +195,7 @@ loop:
195
195
w .connected = true
196
196
}
197
197
198
- ad := w .pending [res .Addr ]
198
+ ad := w .pending [string ( res .Addr . Bytes ()) ]
199
199
200
200
if res .Conn != nil {
201
201
// we got a connection, add it to the swarm
@@ -250,7 +250,7 @@ func (w *dialWorker) dispatchError(ad *addrDial, err error) {
250
250
// accumulate the error
251
251
pr .err .recordErr (ad .addr , err )
252
252
253
- delete (pr .addrs , ad .addr )
253
+ delete (pr .addrs , string ( ad .addr . Bytes ()) )
254
254
if len (pr .addrs ) == 0 {
255
255
// all addrs have erred, dispatch dial error
256
256
// 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) {
274
274
// it is also necessary to preserve consisent behaviour with the old dialer -- TestDialBackoff
275
275
// regresses without this.
276
276
if err == ErrDialBackoff {
277
- delete (w .pending , ad .addr )
277
+ delete (w .pending , string ( ad .addr . Bytes ()) )
278
278
}
279
279
}
280
280
0 commit comments