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

fix staticcheck #96

Merged
merged 2 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package noise

import (
"context"
"golang.org/x/crypto/poly1305"
"io"
"io/ioutil"
"math/rand"
"net"
"testing"
"time"

"golang.org/x/crypto/poly1305"

"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/sec"
)
Expand Down Expand Up @@ -201,11 +202,6 @@ func benchDataTransfer(b *benchenv, dataSize int64, m testMode) {
b.ReportMetric(bytesPerSec, "bytes/sec")
}

type bc struct {
plainTextChunkLen int64
readBufferLen int64
}

func BenchmarkTransfer1MB(b *testing.B) {
for n, bc := range bcs {
b.Run(n, func(b *testing.B) {
Expand Down
10 changes: 5 additions & 5 deletions handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"crypto/rand"
"encoding/binary"
"fmt"
pool "github.com/libp2p/go-buffer-pool"
"golang.org/x/crypto/poly1305"
"time"

"golang.org/x/crypto/poly1305"

"github.com/flynn/noise"
"github.com/gogo/protobuf/proto"

pool "github.com/libp2p/go-buffer-pool"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer"

Expand Down Expand Up @@ -94,8 +95,7 @@ func (s *secureSession) runHandshake(ctx context.Context) error {
}
} else {
// stage 0 //
plaintext, err := s.readHandshakeMessage(hs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this. Why is plaintext never used here?

if err != nil {
if _, err := s.readHandshakeMessage(hs); err != nil {
return fmt.Errorf("error reading handshake message: %w", err)
}

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

// stage 2 //
plaintext, err = s.readHandshakeMessage(hs)
plaintext, err := s.readHandshakeMessage(hs)
if err != nil {
return fmt.Errorf("error reading handshake message: %w", err)
}
Expand Down