diff --git a/CHANGELOG.md b/CHANGELOG.md index c2bdb3f1..f1154baa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,9 +26,19 @@ BUG FIXES: ## 0.19.2 (TBD) +FEATURES: + +- [p2p] Allow peers with different Minor versions to connect + +IMPROVEMENTS: + +- [p2p] Various code comments cleanup + BUG FIXES: -- Fix reconnect to persistent peer when first dial fails +- [p2p] Fix reconnect to persistent peer when first dial fails +- [p2p] Validate NodeInfo.ListenAddr +- [p2p/pex] Limit max msg size to 64kB ## 0.19.1 (April 27th, 2018) diff --git a/p2p/errors.go b/p2p/errors.go index 91b8f96c..f4a09e6c 100644 --- a/p2p/errors.go +++ b/p2p/errors.go @@ -26,7 +26,7 @@ type ErrNetAddressNoID struct { } func (e ErrNetAddressNoID) Error() string { - return fmt.Errorf("Address (%s) does not contain ID", e.Addr) + return fmt.Sprintf("Address (%s) does not contain ID", e.Addr) } type ErrNetAddressInvalid struct { @@ -35,7 +35,7 @@ type ErrNetAddressInvalid struct { } func (e ErrNetAddressInvalid) Error() string { - return fmt.Errorf("Invalid address (%s): %v", e.Addr, e.Err) + return fmt.Sprintf("Invalid address (%s): %v", e.Addr, e.Err) } type ErrNetAddressLookup struct { @@ -44,5 +44,5 @@ type ErrNetAddressLookup struct { } func (e ErrNetAddressLookup) Error() string { - return fmt.Errorf("Error looking up host (%s): %v", e.Addr, e.Err) + return fmt.Sprintf("Error looking up host (%s): %v", e.Addr, e.Err) } diff --git a/p2p/node_info.go b/p2p/node_info.go index 7d149082..5e08cde1 100644 --- a/p2p/node_info.go +++ b/p2p/node_info.go @@ -57,7 +57,7 @@ func (info NodeInfo) Validate() error { } // ensure ListenAddr is good - netAddr, err := NewNetAddressString(IDAddressString(info.ID, info.ListenAddr)) + _, err := NewNetAddressString(IDAddressString(info.ID, info.ListenAddr)) if err != nil { return err } diff --git a/p2p/pex/addrbook.go b/p2p/pex/addrbook.go index aff07b66..a9377347 100644 --- a/p2p/pex/addrbook.go +++ b/p2p/pex/addrbook.go @@ -623,7 +623,7 @@ func (a *addrBook) addAddress(addr, src *p2p.NetAddress) error { } // TODO: we should track ourAddrs by ID and by IP:PORT and refuse both. if _, ok := a.ourAddrs[addr.String()]; ok { - return ErrAddrBookSelf + return ErrAddrBookSelf{addr} } ka := a.addrLookup[addr.ID] diff --git a/p2p/pex/params.go b/p2p/pex/params.go index f94e1021..29b4d45a 100644 --- a/p2p/pex/params.go +++ b/p2p/pex/params.go @@ -50,6 +50,6 @@ const ( minGetSelection = 32 // max addresses returned by GetSelection - // NOTE: this must match "maxPexMessageSize" + // NOTE: this must match "maxMsgSize" maxGetSelection = 250 ) diff --git a/p2p/pex/pex_reactor.go b/p2p/pex/pex_reactor.go index b139e4ab..bb770e7a 100644 --- a/p2p/pex/pex_reactor.go +++ b/p2p/pex/pex_reactor.go @@ -26,8 +26,8 @@ const ( maxAddressSize = 256 // NOTE: amplificaiton factor! - // small request results in up to maxPexMessageSize response - maxPexMessageSize = maxAddressSize * maxGetSelection + // small request results in up to maxMsgSize response + maxMsgSize = maxAddressSize * maxGetSelection // ensure we have enough peers defaultEnsurePeersPeriod = 30 * time.Second diff --git a/p2p/test_util.go b/p2p/test_util.go index fe5282a9..2c90bf51 100644 --- a/p2p/test_util.go +++ b/p2p/test_util.go @@ -49,6 +49,8 @@ func CreateRoutableAddr() (addr string, netAddr *NetAddress) { //------------------------------------------------------------------ // Connects switches via arbitrary net.Conn. Used for testing. +const TEST_HOST = "localhost" + // MakeConnectedSwitches returns n switches, connected according to the connect func. // If connect==Connect2Switches, the switches will be fully connected. // initSwitch defines how the i'th switch should be initialized (ie. with what reactors). @@ -56,7 +58,7 @@ func CreateRoutableAddr() (addr string, netAddr *NetAddress) { func MakeConnectedSwitches(cfg *cfg.P2PConfig, n int, initSwitch func(int, *Switch) *Switch, connect func([]*Switch, int, int)) []*Switch { switches := make([]*Switch, n) for i := 0; i < n; i++ { - switches[i] = MakeSwitch(cfg, i, "testing", "123.123.123", initSwitch) + switches[i] = MakeSwitch(cfg, i, TEST_HOST, "123.123.123", initSwitch) } if err := StartSwitches(switches); err != nil {