mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
whisper: remove unnecessary advertised map and make advertisements more aggressive
This commit is contained in:
parent
f0de0f2230
commit
9294ebbc12
1 changed files with 13 additions and 24 deletions
|
|
@ -35,7 +35,6 @@ type Peer struct {
|
|||
trusted bool
|
||||
|
||||
known *set.Set // Messages already known by the peer to avoid wasting bandwidth
|
||||
advertised map[common.Hash]struct{}
|
||||
hashes chan common.Hash
|
||||
quit chan struct{}
|
||||
}
|
||||
|
|
@ -48,7 +47,6 @@ func newPeer(host *Whisper, remote *p2p.Peer, rw p2p.MsgReadWriter) *Peer {
|
|||
ws: rw,
|
||||
trusted: false,
|
||||
known: set.New(),
|
||||
advertised: make(map[common.Hash]struct{}),
|
||||
hashes: make(chan common.Hash, 20),
|
||||
quit: make(chan struct{}),
|
||||
}
|
||||
|
|
@ -104,8 +102,8 @@ func (p *Peer) update() {
|
|||
// Start the tickers for the updates
|
||||
expire := time.NewTicker(expirationCycle)
|
||||
transmit := time.NewTicker(transmissionCycle)
|
||||
hashesTransmit := time.NewTicker(100 * time.Millisecond)
|
||||
hashes := make([]common.Hash, 0, 10)
|
||||
hashesTransmit := time.NewTicker(20 * time.Millisecond)
|
||||
hashes := make([]common.Hash, 0, 4)
|
||||
// Loop and transmit until termination is requested
|
||||
for {
|
||||
select {
|
||||
|
|
@ -124,9 +122,6 @@ func (p *Peer) update() {
|
|||
}
|
||||
hashes = hashes[:0]
|
||||
case hash := <-p.hashes:
|
||||
if _, ok := p.advertised[hash]; ok {
|
||||
continue
|
||||
}
|
||||
if p.known.Has(hash) {
|
||||
continue
|
||||
}
|
||||
|
|
@ -201,13 +196,7 @@ func (p *Peer) broadcastHashes(hashes []common.Hash) error {
|
|||
return nil
|
||||
}
|
||||
log.Trace("broadcast", "hashes", hashes)
|
||||
if err := p2p.Send(p.ws, hashesCode, hashes); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, hash := range hashes {
|
||||
p.advertised[hash] = struct{}{}
|
||||
}
|
||||
return nil
|
||||
return p2p.Send(p.ws, hashesCode, hashes)
|
||||
}
|
||||
|
||||
func (p *Peer) ID() []byte {
|
||||
|
|
|
|||
Loading…
Reference in a new issue