mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
minor cleanup
This commit is contained in:
parent
fa66694f2e
commit
0cbbb61962
@ -23,6 +23,11 @@ IMPROVEMENTS:
|
||||
BUG FIXES:
|
||||
- Graceful handling/recovery for apps that have non-determinism or fail to halt
|
||||
- Graceful handling/recovery for violations of safety, or liveness
|
||||
|
||||
## 0.19.2 (TBD)
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
- Fix reconnect to persistent peer when first dial fails
|
||||
|
||||
## 0.19.1 (April 27th, 2018)
|
||||
|
@ -1,79 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## 0.5.0 (April 21, 2017)
|
||||
|
||||
BREAKING CHANGES:
|
||||
|
||||
- Remove or unexport methods from FuzzedConnection: Active, Mode, ProbDropRW, ProbDropConn, ProbSleep, MaxDelayMilliseconds, Fuzz
|
||||
- switch.AddPeerWithConnection is unexported and replaced by switch.AddPeer
|
||||
- switch.DialPeerWithAddress takes a bool, setting the peer as persistent or not
|
||||
- PeerConfig requires a Dial function
|
||||
|
||||
FEATURES:
|
||||
|
||||
- Persistent peers: any peer considered a "seed" will be reconnected to when the connection is dropped
|
||||
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
- Many more tests and comments
|
||||
- Refactor configurations for less dependence on go-config. Introduces new structs PeerConfig, MConnConfig, FuzzConnConfig
|
||||
- New methods on peer: CloseConn, HandshakeTimeout, IsPersistent, Addr, PubKey
|
||||
- NewNetAddress supports a testing mode where the address defaults to 0.0.0.0:0
|
||||
|
||||
|
||||
## 0.4.0 (March 6, 2017)
|
||||
|
||||
BREAKING CHANGES:
|
||||
|
||||
- DialSeeds now takes an AddrBook and returns an error: `DialSeeds(*AddrBook, []string) error`
|
||||
- NewNetAddressString now returns an error: `NewNetAddressString(string) (*NetAddress, error)`
|
||||
|
||||
FEATURES:
|
||||
|
||||
- `NewNetAddressStrings([]string) ([]*NetAddress, error)`
|
||||
- `AddrBook.Save()`
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
- PexReactor responsible for starting and stopping the AddrBook
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
- DialSeeds returns an error instead of panicking on bad addresses
|
||||
|
||||
## 0.3.5 (January 12, 2017)
|
||||
|
||||
FEATURES
|
||||
|
||||
- Toggle strict routability in the AddrBook
|
||||
|
||||
BUG FIXES
|
||||
|
||||
- Close filtered out connections
|
||||
- Fixes for MakeConnectedSwitches and Connect2Switches
|
||||
|
||||
## 0.3.4 (August 10, 2016)
|
||||
|
||||
FEATURES:
|
||||
|
||||
- Optionally filter connections by address or public key
|
||||
|
||||
## 0.3.3 (May 12, 2016)
|
||||
|
||||
FEATURES:
|
||||
|
||||
- FuzzConn
|
||||
|
||||
## 0.3.2 (March 12, 2016)
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
- Memory optimizations
|
||||
|
||||
## 0.3.1 ()
|
||||
|
||||
FEATURES:
|
||||
|
||||
- Configurable parameters
|
||||
|
10
p2p/peer.go
10
p2p/peer.go
@ -90,7 +90,7 @@ type PeerConfig struct {
|
||||
|
||||
MConfig *tmconn.MConnConfig `mapstructure:"connection"`
|
||||
|
||||
Fail bool `mapstructure:"fail"` // for testing
|
||||
DialFail bool `mapstructure:"dial_fail"` // for testing
|
||||
Fuzz bool `mapstructure:"fuzz"` // fuzz connection (for testing)
|
||||
FuzzConfig *FuzzConnConfig `mapstructure:"fuzz_config"`
|
||||
}
|
||||
@ -102,7 +102,7 @@ func DefaultPeerConfig() *PeerConfig {
|
||||
HandshakeTimeout: 20, // * time.Second,
|
||||
DialTimeout: 3, // * time.Second,
|
||||
MConfig: tmconn.DefaultMConnConfig(),
|
||||
Fail: false,
|
||||
DialFail: false,
|
||||
Fuzz: false,
|
||||
FuzzConfig: DefaultFuzzConnConfig(),
|
||||
}
|
||||
@ -339,7 +339,11 @@ func (p *peer) String() string {
|
||||
//------------------------------------------------------------------
|
||||
// helper funcs
|
||||
|
||||
var dial = func(addr *NetAddress, config *PeerConfig) (net.Conn, error) {
|
||||
func dial(addr *NetAddress, config *PeerConfig) (net.Conn, error) {
|
||||
if config.DialFail {
|
||||
return nil, fmt.Errorf("dial err (peerConfig.DialFail == true)")
|
||||
}
|
||||
|
||||
conn, err := addr.DialTimeout(config.DialTimeout * time.Second)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -283,11 +283,12 @@ func (sw *Switch) stopAndRemovePeer(peer Peer, reason interface{}) {
|
||||
// with a fixed interval, then with exponential backoff.
|
||||
// If no success after all that, it stops trying, and leaves it
|
||||
// to the PEX/Addrbook to find the peer with the addr again
|
||||
// NOTE: this will keep trying even if the handshake or auth fails.
|
||||
// TODO: be more explicit with error types so we only retry on certain failures
|
||||
func (sw *Switch) reconnectToPeer(addr *NetAddress) {
|
||||
if sw.reconnecting.Has(string(addr.ID)) {
|
||||
return
|
||||
}
|
||||
|
||||
sw.reconnecting.Set(string(addr.ID), addr)
|
||||
defer sw.reconnecting.Delete(string(addr.ID))
|
||||
|
||||
@ -381,13 +382,14 @@ func (sw *Switch) DialPeersAsync(addrBook AddrBook, peers []string, persistent b
|
||||
go func(i int) {
|
||||
j := perm[i]
|
||||
|
||||
addr := netAddrs[j]
|
||||
// do not dial ourselves
|
||||
if netAddrs[j].Same(ourAddr) {
|
||||
if addr.Same(ourAddr) {
|
||||
return
|
||||
}
|
||||
|
||||
sw.randomSleep(0)
|
||||
err := sw.DialPeerWithAddress(netAddrs[j], persistent)
|
||||
err := sw.DialPeerWithAddress(addr, persistent)
|
||||
if err != nil {
|
||||
sw.Logger.Error("Error dialing peer", "err", err)
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@ -23,20 +22,9 @@ var (
|
||||
config *cfg.P2PConfig
|
||||
)
|
||||
|
||||
var goodDial = dial
|
||||
|
||||
// badDial returns an error for testing dial errors
|
||||
func badDial(addr *NetAddress, config *PeerConfig) (net.Conn, error) {
|
||||
if config.Fail {
|
||||
return nil, errors.New("dial err")
|
||||
}
|
||||
return goodDial(addr, config)
|
||||
}
|
||||
|
||||
func init() {
|
||||
config = cfg.DefaultP2PConfig()
|
||||
config.PexReactor = true
|
||||
dial = badDial
|
||||
}
|
||||
|
||||
type PeerMessage struct {
|
||||
@ -329,13 +317,13 @@ func TestSwitchReconnectsToPersistentPeer(t *testing.T) {
|
||||
assert.False(peer.IsRunning())
|
||||
|
||||
// simulate another remote peer
|
||||
rp = &remotePeer{PrivKey: crypto.GenPrivKeyEd25519().Wrap(), Config: DefaultPeerConfig()}
|
||||
rp = &remotePeer{PrivKey: crypto.GenPrivKeyEd25519(), Config: DefaultPeerConfig()}
|
||||
rp.Start()
|
||||
defer rp.Stop()
|
||||
|
||||
// simulate first time dial failure
|
||||
peerConfig := DefaultPeerConfig()
|
||||
peerConfig.Fail = true
|
||||
peerConfig.DialFail = true
|
||||
err = sw.addOutboundPeerWithConfig(rp.Addr(), peerConfig, true)
|
||||
require.NotNil(err)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user