Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-routing
Commits
2f0a7ef8
Commit
2f0a7ef8
authored
Jan 28, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(gcr/c) randomize order of remotes
parent
22d8d5c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
grandcentral/proxy/standard.go
grandcentral/proxy/standard.go
+6
-2
No files found.
grandcentral/proxy/standard.go
View file @
2f0a7ef8
package
proxy
import
(
"math/rand"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ggio
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/io"
host
"github.com/jbenet/go-ipfs/p2p/host"
...
...
@@ -36,7 +38,8 @@ func (p *standard) HandleStream(s inet.Stream) {
func
(
px
*
standard
)
SendMessage
(
ctx
context
.
Context
,
m
*
dhtpb
.
Message
)
error
{
var
err
error
for
_
,
remote
:=
range
px
.
Remotes
{
for
_
,
i
:=
range
rand
.
Perm
(
len
(
px
.
Remotes
))
{
remote
:=
px
.
Remotes
[
i
]
if
err
=
px
.
sendMessage
(
ctx
,
m
,
remote
);
err
!=
nil
{
// careful don't re-declare err!
continue
}
...
...
@@ -63,7 +66,8 @@ func (px *standard) sendMessage(ctx context.Context, m *dhtpb.Message, remote pe
func
(
px
*
standard
)
SendRequest
(
ctx
context
.
Context
,
m
*
dhtpb
.
Message
)
(
*
dhtpb
.
Message
,
error
)
{
var
err
error
for
_
,
remote
:=
range
px
.
Remotes
{
for
_
,
i
:=
range
rand
.
Perm
(
len
(
px
.
Remotes
))
{
remote
:=
px
.
Remotes
[
i
]
var
reply
*
dhtpb
.
Message
reply
,
err
=
px
.
sendRequest
(
ctx
,
m
,
remote
)
// careful don't redeclare err!
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment