Skip to content

Commit

Permalink
peer: various cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi authored and davecgh committed Oct 17, 2020
1 parent c967d67 commit c07fa09
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion peer/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func invSummary(invList []*wire.InvVect) string {
return fmt.Sprintf("block %s", iv.Hash)
case wire.InvTypeTx:
return fmt.Sprintf("tx %s", iv.Hash)
case wire.InvTypeFilteredBlock:
return fmt.Sprintf("filtered block %s", iv.Hash)
}

return fmt.Sprintf("unknown (%d) %s", uint32(iv.Type), iv.Hash)
Expand Down Expand Up @@ -198,7 +200,6 @@ func messageSummary(msg wire.Message) string {
return fmt.Sprintf("blockHashes %d, voteHashes %d, tspendHashes %d",
len(msg.BlockHashes), len(msg.VoteHashes),
len(msg.TSpendHashes))

}

// No summary for other messages.
Expand Down
2 changes: 1 addition & 1 deletion peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func newNetAddress(addr net.Addr, services wire.ServiceFlag) (*wire.NetAddress,

// outMsg is used to house a message to be sent along with a channel to signal
// when the message has been sent (or won't be sent due to things such as
// shutdown)
// shutdown).
type outMsg struct {
msg wire.Message
doneChan chan<- struct{}
Expand Down
9 changes: 5 additions & 4 deletions peer/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c conn) SetDeadline(t time.Time) error { return nil }
func (c conn) SetReadDeadline(t time.Time) error { return nil }
func (c conn) SetWriteDeadline(t time.Time) error { return nil }

// addr mocks a network address
// addr mocks a network address.
type addr struct {
net, address string
}
Expand Down Expand Up @@ -106,7 +106,7 @@ type peerStats struct {
wantBytesReceived uint64
}

// testPeer tests the given peer's flags and stats
// testPeer tests the given peer's flags and stats.
func testPeer(t *testing.T, p *Peer, s peerStats) {
if p.UserAgent() != s.wantUserAgent {
t.Errorf("testPeer: wrong UserAgent - got %v, want %v", p.UserAgent(), s.wantUserAgent)
Expand Down Expand Up @@ -536,7 +536,8 @@ func TestPeerListeners(t *testing.T) {
{
"OnCFTypes",
wire.NewMsgCFTypes([]wire.FilterType{
wire.GCSFilterRegular, wire.GCSFilterExtended}),
wire.GCSFilterRegular, wire.GCSFilterExtended,
}),
},
{
"OnFeeFilter",
Expand Down Expand Up @@ -643,7 +644,7 @@ func TestOutboundPeer(t *testing.T) {
p.Disconnect()

// Test NewestBlock
var newestBlock = func() (*chainhash.Hash, int64, error) {
newestBlock := func() (*chainhash.Hash, int64, error) {
hashStr := "14a0810ac680a3eb3f82edc878cea25ec41d6b790744e5daeef"
hash, err := chainhash.NewHashFromStr(hashStr)
if err != nil {
Expand Down

0 comments on commit c07fa09

Please sign in to comment.