mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
p2p: fix switch test for Broadcast returning success channel
This commit is contained in:
parent
21530bf00f
commit
a2938fd35b
@ -166,7 +166,7 @@ func (sw *Switch) IsDialing(addr *NetAddress) bool {
|
|||||||
// which receives success values for each attempted send (false if times out)
|
// which receives success values for each attempted send (false if times out)
|
||||||
func (sw *Switch) Broadcast(chId byte, msg interface{}) chan bool {
|
func (sw *Switch) Broadcast(chId byte, msg interface{}) chan bool {
|
||||||
if atomic.LoadUint32(&sw.stopped) == 1 {
|
if atomic.LoadUint32(&sw.stopped) == 1 {
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
successChan := make(chan bool, len(sw.peers.List()))
|
successChan := make(chan bool, len(sw.peers.List()))
|
||||||
log.Debug("Broadcast", "channel", chId, "msg", msg)
|
log.Debug("Broadcast", "channel", chId, "msg", msg)
|
||||||
|
@ -197,9 +197,14 @@ func BenchmarkSwitches(b *testing.B) {
|
|||||||
// Send random message from one channel to another
|
// Send random message from one channel to another
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
chId := byte(i % 4)
|
chId := byte(i % 4)
|
||||||
nS, nF := s1.Broadcast(chId, "test data")
|
successChan := s1.Broadcast(chId, "test data")
|
||||||
numSuccess += nS
|
for s := range successChan {
|
||||||
numFailure += nF
|
if s {
|
||||||
|
numSuccess += 1
|
||||||
|
} else {
|
||||||
|
numFailure += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Warn(Fmt("success: %v, failure: %v", numSuccess, numFailure))
|
log.Warn(Fmt("success: %v, failure: %v", numSuccess, numFailure))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user