Commit 613ed7ed authored by Hector Sanjuan's avatar Hector Sanjuan
Browse files

net/mock: Make golint happier



License: MIT
Signed-off-by: default avatarHector Sanjuan <hector@protocol.ai>
parent 040c881b
......@@ -19,6 +19,10 @@ import (
ma "github.com/multiformats/go-multiaddr"
)
// Mocknet is an interface representing a network of peers. Each peer
// has its own net.Network. Mocknet can add and remove peers,
// link different networks and provide a representation of the state
// of the system via LinkMaps.
type Mocknet interface {
// GenPeer generates a peer and its inet.Network in the Mocknet
......
......@@ -38,6 +38,7 @@ type mocknet struct {
sync.Mutex
}
// New initializes and returns a default implementation of Mocknet.
func New(ctx context.Context) Mocknet {
return &mocknet{
nets: map[peer.ID]*peernet{},
......
......@@ -26,6 +26,7 @@ type transportObject struct {
arrivalTime time.Time
}
// NewStream returns a new mock stream, which implements net.Stream.
func NewStream(p net.Conn) *stream {
s := &stream{
Pipe: p,
......
......@@ -17,7 +17,7 @@ type ratelimiter struct {
duration time.Duration // total delay introduced due to rate limiting
}
// Creates a new ratelimiter with bandwidth (in bytes/sec)
// NewRatelimiter creates a new ratelimiter with bandwidth (in bytes/sec)
func NewRatelimiter(bandwidth float64) *ratelimiter {
// convert bandwidth to bytes per nanosecond
b := bandwidth / float64(time.Second)
......@@ -47,7 +47,7 @@ func (r *ratelimiter) Limit(dataSize int) time.Duration {
r.lock.Lock()
defer r.lock.Unlock()
// update time
var duration time.Duration = time.Duration(0)
var duration = time.Duration(0)
if r.bandwidth == 0 {
return duration
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment