aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-14 18:49:15 +0800
committerobscuren <geffobscura@gmail.com>2015-04-14 18:49:15 +0800
commit9800c84348b5492dd87802f82ef54c5b9676a52a (patch)
tree266bd7b9f721b0091c14033b0f519ad463c7a1cf /eth/backend.go
parent8310bcda6100cc703f5c1e22e0122ad7476d689d (diff)
downloadgo-tangerine-9800c84348b5492dd87802f82ef54c5b9676a52a.tar.gz
go-tangerine-9800c84348b5492dd87802f82ef54c5b9676a52a.tar.zst
go-tangerine-9800c84348b5492dd87802f82ef54c5b9676a52a.zip
eth: limit the amount of peers that will receive Block/Tx messages
All transaction and block messages are now limited using `sqrt(peers)`
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/eth/backend.go b/eth/backend.go
index f073ec6e6..cde7b167d 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -4,6 +4,7 @@ import (
"crypto/ecdsa"
"fmt"
"io/ioutil"
+ "math"
"path"
"strings"
@@ -448,7 +449,7 @@ func (self *Ethereum) txBroadcastLoop() {
// automatically stops if unsubscribe
for obj := range self.txSub.Chan() {
event := obj.(core.TxPreEvent)
- self.net.Broadcast("eth", TxMsg, []*types.Transaction{event.Tx})
+ self.net.BroadcastLimited("eth", TxMsg, math.Sqrt, []*types.Transaction{event.Tx})
self.syncAccounts(event.Tx)
}
}
@@ -472,7 +473,7 @@ func (self *Ethereum) blockBroadcastLoop() {
for obj := range self.blockSub.Chan() {
switch ev := obj.(type) {
case core.ChainHeadEvent:
- self.net.Broadcast("eth", NewBlockMsg, []interface{}{ev.Block, ev.Block.Td})
+ self.net.BroadcastLimited("eth", NewBlockMsg, math.Sqrt, []interface{}{ev.Block, ev.Block.Td})
}
}
}