Skip to content
This repository was archived by the owner on May 26, 2022. It is now read-only.

Commit 1bd1ecf

Browse files
authored
Merge pull request #96 from libp2p/fix-staticcheck
fix staticcheck
2 parents cfe523c + 88d9a76 commit 1bd1ecf

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

benchmark_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package noise
22

33
import (
44
"context"
5-
"golang.org/x/crypto/poly1305"
65
"io"
76
"io/ioutil"
87
"math/rand"
98
"net"
109
"testing"
1110
"time"
1211

12+
"golang.org/x/crypto/poly1305"
13+
1314
"github.com/libp2p/go-libp2p-core/crypto"
1415
"github.com/libp2p/go-libp2p-core/sec"
1516
)
@@ -201,11 +202,6 @@ func benchDataTransfer(b *benchenv, dataSize int64, m testMode) {
201202
b.ReportMetric(bytesPerSec, "bytes/sec")
202203
}
203204

204-
type bc struct {
205-
plainTextChunkLen int64
206-
readBufferLen int64
207-
}
208-
209205
func BenchmarkTransfer1MB(b *testing.B) {
210206
for n, bc := range bcs {
211207
b.Run(n, func(b *testing.B) {

handshake.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"crypto/rand"
66
"encoding/binary"
77
"fmt"
8-
pool "github.com/libp2p/go-buffer-pool"
9-
"golang.org/x/crypto/poly1305"
108
"time"
119

10+
"golang.org/x/crypto/poly1305"
11+
1212
"github.com/flynn/noise"
1313
"github.com/gogo/protobuf/proto"
1414

15+
pool "github.com/libp2p/go-buffer-pool"
1516
"github.com/libp2p/go-libp2p-core/crypto"
1617
"github.com/libp2p/go-libp2p-core/peer"
1718

@@ -94,8 +95,8 @@ func (s *secureSession) runHandshake(ctx context.Context) error {
9495
}
9596
} else {
9697
// stage 0 //
97-
plaintext, err := s.readHandshakeMessage(hs)
98-
if err != nil {
98+
// We don't expect any payload on the first message.
99+
if _, err := s.readHandshakeMessage(hs); err != nil {
99100
return fmt.Errorf("error reading handshake message: %w", err)
100101
}
101102

@@ -108,7 +109,7 @@ func (s *secureSession) runHandshake(ctx context.Context) error {
108109
}
109110

110111
// stage 2 //
111-
plaintext, err = s.readHandshakeMessage(hs)
112+
plaintext, err := s.readHandshakeMessage(hs)
112113
if err != nil {
113114
return fmt.Errorf("error reading handshake message: %w", err)
114115
}

0 commit comments

Comments
 (0)