Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
1c10ed41
Commit
1c10ed41
authored
8 years ago
by
Jeromy Johnson
Committed by
GitHub
8 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #148 from libp2p/feat/stream-deadlines
update dependencies and add deadline methods to streams
parents
bb6a43ca
6f804db7
master
2018-Q4-OKR
docs-improvements
feat/p2p-multiaddr
feat/pnet/working3
feat/protobuf
feat/relay-integrate
feat/udp
feature/standardize-readme
fix/473
fix/no-custom-field
fix/reset-ping-stream
fix/revert-correct-external-addr
gx/update-jccl6u
gx/update-nza0mn
jenkinsfile
kevina/fix-go-vet
multistream-ping
punching
revert-276-update-go-detect-race
v6.0.23
v6.0.22
v6.0.21
v6.0.20
v6.0.19
v6.0.18
v6.0.17
v6.0.16
v6.0.15
v6.0.14
v6.0.13
v6.0.12
v6.0.11
v6.0.10
v6.0.9
v6.0.8
v6.0.7
v6.0.6
v6.0.5
v6.0.4
v6.0.3
v6.0.2
v6.0.1
v6.0.0
v5.0.21
v5.0.20
v5.0.19
v5.0.18
v5.0.17
v5.0.16
v5.0.15
v5.0.14
v5.0.13
v5.0.12
v5.0.11
v5.0.10
v5.0.9
v5.0.8
v5.0.7
v5.0.6
v5.0.5
v5.0.4
v5.0.3
v5.0.2
v5.0.1
v5.0.0
v4.5.5
v4.5.4
v4.5.3
v4.5.2
v4.5.1
v4.5.0
v4.4.5
v4.4.4
v4.4.3
v4.4.2
v4.4.1
v4.4.0
v4.3.12
v4.3.11
v4.3.10
v4.3.9
v4.3.8
v4.3.7
v4.3.6
v4.3.5
v4.3.4
v4.3.3
v4.3.2
v4.3.1
v4.3.0
v4.2.0
v4.1.0
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
p2p/host/basic/basic_host.go
+1
-1
p2p/host/basic/basic_host.go
p2p/net/mock/mock_link.go
+4
-5
p2p/net/mock/mock_link.go
p2p/net/mock/mock_stream.go
+23
-13
p2p/net/mock/mock_stream.go
package.json
+10
-33
package.json
with
38 additions
and
52 deletions
+38
-52
p2p/host/basic/basic_host.go
View file @
1c10ed41
...
...
@@ -21,7 +21,7 @@ import (
msmux
"github.com/whyrusleeping/go-multistream"
)
var
log
=
logging
.
Logger
(
"
github.com/libp2p/go-libp2p/p2p/host/
basic"
)
var
log
=
logging
.
Logger
(
"basic
host
"
)
// Option is a type used to pass in options to the host.
type
Option
int
...
...
This diff is collapsed.
Click to expand it.
p2p/net/mock/mock_link.go
View file @
1c10ed41
...
...
@@ -2,7 +2,7 @@ package mocknet
import
(
// "fmt"
"
io
"
"
net
"
"sync"
"time"
...
...
@@ -45,11 +45,10 @@ func (l *link) newConnPair(dialer *peernet) (*conn, *conn) {
}
func
(
l
*
link
)
newStreamPair
()
(
*
stream
,
*
stream
)
{
r1
,
w1
:=
io
.
Pipe
()
r2
,
w2
:=
io
.
Pipe
()
a
,
b
:=
net
.
Pipe
()
s1
:=
NewStream
(
w2
,
r1
)
s2
:=
NewStream
(
w1
,
r2
)
s1
:=
NewStream
(
a
)
s2
:=
NewStream
(
b
)
return
s1
,
s2
}
...
...
This diff is collapsed.
Click to expand it.
p2p/net/mock/mock_stream.go
View file @
1c10ed41
...
...
@@ -3,6 +3,7 @@ package mocknet
import
(
"bytes"
"io"
"net"
"time"
process
"github.com/jbenet/goprocess"
...
...
@@ -12,8 +13,7 @@ import (
// stream implements inet.Stream
type
stream
struct
{
io
.
Reader
io
.
Writer
Pipe
net
.
Conn
conn
*
conn
toDeliver
chan
*
transportObject
proc
process
.
Process
...
...
@@ -26,10 +26,9 @@ type transportObject struct {
arrivalTime
time
.
Time
}
func
NewStream
(
w
io
.
Writer
,
r
io
.
Reader
)
*
stream
{
func
NewStream
(
p
net
.
Conn
)
*
stream
{
s
:=
&
stream
{
Reader
:
r
,
Writer
:
w
,
Pipe
:
p
,
toDeliver
:
make
(
chan
*
transportObject
),
}
...
...
@@ -70,12 +69,7 @@ func (s *stream) teardown() error {
// at this point, no streams are writing.
s
.
conn
.
removeStream
(
s
)
if
r
,
ok
:=
(
s
.
Reader
)
.
(
io
.
Closer
);
ok
{
r
.
Close
()
}
if
w
,
ok
:=
(
s
.
Writer
)
.
(
io
.
Closer
);
ok
{
w
.
Close
()
}
s
.
Pipe
.
Close
()
s
.
conn
.
net
.
notifyAll
(
func
(
n
inet
.
Notifiee
)
{
n
.
ClosedStream
(
s
.
conn
.
net
,
s
)
})
...
...
@@ -86,6 +80,22 @@ func (s *stream) Conn() inet.Conn {
return
s
.
conn
}
func
(
s
*
stream
)
SetDeadline
(
t
time
.
Time
)
error
{
return
s
.
Pipe
.
SetDeadline
(
t
)
}
func
(
s
*
stream
)
SetReadDeadline
(
t
time
.
Time
)
error
{
return
s
.
Pipe
.
SetReadDeadline
(
t
)
}
func
(
s
*
stream
)
SetWriteDeadline
(
t
time
.
Time
)
error
{
return
s
.
Pipe
.
SetWriteDeadline
(
t
)
}
func
(
s
*
stream
)
Read
(
b
[]
byte
)
(
int
,
error
)
{
return
s
.
Pipe
.
Read
(
b
)
}
// transport will grab message arrival times, wait until that time, and
// then write the message out when it is scheduled to arrive
func
(
s
*
stream
)
transport
(
proc
process
.
Process
)
{
...
...
@@ -97,7 +107,7 @@ func (s *stream) transport(proc process.Process) {
// done only when arrival time makes sense.
drainBuf
:=
func
()
{
if
buf
.
Len
()
>
0
{
_
,
err
:=
s
.
Writer
.
Write
(
buf
.
Bytes
())
_
,
err
:=
s
.
Pipe
.
Write
(
buf
.
Bytes
())
if
err
!=
nil
{
return
}
...
...
@@ -131,7 +141,7 @@ func (s *stream) transport(proc process.Process) {
drainBuf
()
// write this message.
_
,
err
:=
s
.
Writer
.
Write
(
o
.
msg
)
_
,
err
:=
s
.
Pipe
.
Write
(
o
.
msg
)
if
err
!=
nil
{
log
.
Error
(
"mock_stream"
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
package.json
View file @
1c10ed41
...
...
@@ -98,11 +98,6 @@
"name"
:
"randbo"
,
"version"
:
"0.0.0"
},
{
"hash"
:
"Qmb1US8uyZeEpMyc56wVZy2cDFdQjNFojAUYVCoo9ieTqp"
,
"name"
:
"go-stream-muxer"
,
"version"
:
"1.0.0"
},
{
"hash"
:
"QmeQW4ayVqi7Jjay1SrP2wYydsH9KwSrzQBnqyC25gPFnG"
,
"name"
:
"go-notifier"
,
...
...
@@ -114,9 +109,9 @@
"version"
:
"0.0.0"
},
{
"hash"
:
"Qm
S9en3mcwW2HRSeRabceJEGVxTZF4vEeFm7JHWQwWsb1U
"
,
"hash"
:
"Qm
VwFjMdejJ8mGVmgyR2mKcUHrvNBDtDsKRT99soVbkFhA
"
,
"name"
:
"go-peerstream"
,
"version"
:
"1.
4.1
"
"version"
:
"1.
5.0
"
},
{
"author"
:
"whyrusleeping"
,
...
...
@@ -142,24 +137,6 @@
"name"
:
"go-libp2p-secio"
,
"version"
:
"1.1.0"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"QmSHTSkxXGQgaHWz91oZV3CDy3hmKmDgpjbYRT6niACG4E"
,
"name"
:
"go-smux-yamux"
,
"version"
:
"1.1.1"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"QmetupZ62uEdoqNsbZUCgqU3JyfssExBfqBwBhDpjyE6eW"
,
"name"
:
"go-smux-multistream"
,
"version"
:
"1.4.0"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"QmfXgTygwsTPyUWPWTAeBK6cFtTdMqmeeqhyhcNMhRpT1g"
,
"name"
:
"go-smux-spdystream"
,
"version"
:
"1.1.1"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"QmXXCcQ7CLg5a81Ui9TTR35QcR4y7ZyihxwfjqaHfUVcVo"
,
...
...
@@ -216,15 +193,15 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
dysBu77i3YaagNtMAjiCJdeWWvds18ho5XEB784guQ4
1"
,
"hash"
:
"Qm
U3pGGVT1riXp5dBJbNrGpxssVScfvk9236drRHZZbKJ
1"
,
"name"
:
"go-libp2p-net"
,
"version"
:
"1.
5
.0"
"version"
:
"1.
6
.0"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
VcNzHewFvmVah1CGqg8NV7nHHsPu19U43YE5b2oqWyBp
"
,
"hash"
:
"Qm
X4j1JhubdEt4EB1JY1mMKTvJwPZSRzTv3uwh5zaDqyAi
"
,
"name"
:
"go-libp2p-metrics"
,
"version"
:
"1.
5
.0"
"version"
:
"1.
6
.0"
},
{
"author"
:
"whyrusleeping"
,
...
...
@@ -234,15 +211,15 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
Wf338UyG5DKyemvoFiomDPtkVNHLsw3GAt9XXHX5ZtsM
"
,
"hash"
:
"Qm
U5qKZsCG1Wg38jwg8XezBdc3fBGMMZjM7YFMAhunC1Yh
"
,
"name"
:
"go-libp2p-host"
,
"version"
:
"1.
1.1
"
"version"
:
"1.
2.0
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
cjMKTqrWgMMCExEnwczefhno5fvx7FHDV63peZwDzHNF
"
,
"hash"
:
"Qm
U9ePpXRQgGpPpMAm1CsgU9KptrtgZERrVBGB7Ek5cM2D
"
,
"name"
:
"go-libp2p-swarm"
,
"version"
:
"1.
3.3
"
"version"
:
"1.
4.0
"
},
{
"author"
:
"whyrusleeping"
,
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help