mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-25 18:51:39 +00:00
fix AddPeerWithConnection
This commit is contained in:
10
switch.go
10
switch.go
@ -441,7 +441,7 @@ func (sw *Switch) listenerRoutine(l Listener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New inbound connection!
|
// New inbound connection!
|
||||||
err := sw.AddPeerWithConnection(inConn, false, sw.reactorsByCh, sw.chDescs, sw.StopPeerForError, sw.config, sw.nodePrivKey)
|
err := sw.AddPeerWithConnection(inConn, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Notice("Ignoring inbound connection: error while adding peer", "address", inConn.RemoteAddr().String(), "error", err)
|
log.Notice("Ignoring inbound connection: error while adding peer", "address", inConn.RemoteAddr().String(), "error", err)
|
||||||
continue
|
continue
|
||||||
@ -503,14 +503,14 @@ func Connect2Switches(switches []*Switch, i, j int) {
|
|||||||
c1, c2 := net.Pipe()
|
c1, c2 := net.Pipe()
|
||||||
doneCh := make(chan struct{})
|
doneCh := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
err := switchI.AddPeerWithConnection(c1, false, switchI.reactorsByCh, switchI.chDescs, switchI.StopPeerForError, switchI.config, switchI.nodePrivKey)
|
err := switchI.AddPeerWithConnection(c1, false)
|
||||||
if PanicOnAddPeerErr && err != nil {
|
if PanicOnAddPeerErr && err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
doneCh <- struct{}{}
|
doneCh <- struct{}{}
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
err := switchJ.AddPeerWithConnection(c2, false, switchJ.reactorsByCh, switchJ.chDescs, switchJ.StopPeerForError, switchJ.config, switchJ.nodePrivKey)
|
err := switchJ.AddPeerWithConnection(c2, false)
|
||||||
if PanicOnAddPeerErr && err != nil {
|
if PanicOnAddPeerErr && err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -546,8 +546,8 @@ func makeSwitch(i int, network, version string, initSwitch func(int, *Switch) *S
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddPeerWithConnection creates a newPeer from the connection, performs the handshake, and adds it to the switch.
|
// AddPeerWithConnection creates a newPeer from the connection, performs the handshake, and adds it to the switch.
|
||||||
func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool, reactorsByCh map[byte]Reactor, chDescs []*ChannelDescriptor, onPeerError func(*Peer, interface{}), config cfg.Config, privKey crypto.PrivKeyEd25519) error {
|
func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) error {
|
||||||
peer, err := newPeerFromExistingConn(conn, outbound, reactorsByCh, chDescs, onPeerError, config, privKey)
|
peer, err := newPeerFromExistingConn(conn, outbound, sw.reactorsByCh, sw.chDescs, sw.StopPeerForError, sw.config, sw.nodePrivKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
peer.CloseConn()
|
peer.CloseConn()
|
||||||
return err
|
return err
|
||||||
|
@ -178,10 +178,10 @@ func TestConnAddrFilter(t *testing.T) {
|
|||||||
|
|
||||||
// connect to good peer
|
// connect to good peer
|
||||||
go func() {
|
go func() {
|
||||||
s1.AddPeerWithConnection(c1, false, s1.reactorsByCh, s1.chDescs, s1.StopPeerForError, s1.config, s1.nodePrivKey)
|
s1.AddPeerWithConnection(c1, false)
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
s2.AddPeerWithConnection(c2, true, s2.reactorsByCh, s2.chDescs, s2.StopPeerForError, s2.config, s2.nodePrivKey)
|
s2.AddPeerWithConnection(c2, true)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait for things to happen, peers to get added...
|
// Wait for things to happen, peers to get added...
|
||||||
@ -213,10 +213,10 @@ func TestConnPubKeyFilter(t *testing.T) {
|
|||||||
|
|
||||||
// connect to good peer
|
// connect to good peer
|
||||||
go func() {
|
go func() {
|
||||||
s1.AddPeerWithConnection(c1, false, s1.reactorsByCh, s1.chDescs, s1.StopPeerForError, s1.config, s1.nodePrivKey)
|
s1.AddPeerWithConnection(c1, false)
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
s2.AddPeerWithConnection(c2, true, s2.reactorsByCh, s2.chDescs, s2.StopPeerForError, s2.config, s2.nodePrivKey)
|
s2.AddPeerWithConnection(c2, true)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Wait for things to happen, peers to get added...
|
// Wait for things to happen, peers to get added...
|
||||||
|
Reference in New Issue
Block a user