fix build and test

This commit is contained in:
Ethan Buchman 2018-04-28 15:39:09 -04:00
parent 0450e35d67
commit 64569b15e5
7 changed files with 22 additions and 10 deletions

View File

@ -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)

View File

@ -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)
}

View File

@ -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
}

View File

@ -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]

View File

@ -50,6 +50,6 @@ const (
minGetSelection = 32
// max addresses returned by GetSelection
// NOTE: this must match "maxPexMessageSize"
// NOTE: this must match "maxMsgSize"
maxGetSelection = 250
)

View File

@ -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

View File

@ -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 {