mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
whisperv6: remove a few duplicated code
This commit is contained in:
parent
f08f596a37
commit
2e9d1502d4
2 changed files with 16 additions and 26 deletions
|
|
@ -18,26 +18,12 @@ package whisperv6
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/ecdsa"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
mapset "github.com/deckarep/golang-set"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
|
func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
|
||||||
w := &Whisper{
|
w := newDefaultWhisper()
|
||||||
privateKeys: make(map[string]*ecdsa.PrivateKey),
|
|
||||||
symKeys: make(map[string][]byte),
|
|
||||||
envelopes: make(map[common.Hash]*Envelope),
|
|
||||||
expirations: make(map[uint32]mapset.Set),
|
|
||||||
peers: make(map[*Peer]struct{}),
|
|
||||||
messageQueue: make(chan *Envelope, messageQueueLimit),
|
|
||||||
p2pMsgQueue: make(chan *Envelope, messageQueueLimit),
|
|
||||||
quit: make(chan struct{}),
|
|
||||||
syncAllowance: DefaultSyncAllowance,
|
|
||||||
}
|
|
||||||
w.filters = NewFilters(w)
|
w.filters = NewFilters(w)
|
||||||
|
|
||||||
keyID, err := w.GenerateSymKey()
|
keyID, err := w.GenerateSymKey()
|
||||||
|
|
|
||||||
|
|
@ -96,17 +96,7 @@ func New(cfg *Config) *Whisper {
|
||||||
cfg = &DefaultConfig
|
cfg = &DefaultConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
whisper := &Whisper{
|
whisper := newDefaultWhisper()
|
||||||
privateKeys: make(map[string]*ecdsa.PrivateKey),
|
|
||||||
symKeys: make(map[string][]byte),
|
|
||||||
envelopes: make(map[common.Hash]*Envelope),
|
|
||||||
expirations: make(map[uint32]mapset.Set),
|
|
||||||
peers: make(map[*Peer]struct{}),
|
|
||||||
messageQueue: make(chan *Envelope, messageQueueLimit),
|
|
||||||
p2pMsgQueue: make(chan *Envelope, messageQueueLimit),
|
|
||||||
quit: make(chan struct{}),
|
|
||||||
syncAllowance: DefaultSyncAllowance,
|
|
||||||
}
|
|
||||||
|
|
||||||
whisper.filters = NewFilters(whisper)
|
whisper.filters = NewFilters(whisper)
|
||||||
|
|
||||||
|
|
@ -133,6 +123,20 @@ func New(cfg *Config) *Whisper {
|
||||||
return whisper
|
return whisper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newDefaultWhisper() *Whisper {
|
||||||
|
return &Whisper{
|
||||||
|
privateKeys: make(map[string]*ecdsa.PrivateKey),
|
||||||
|
symKeys: make(map[string][]byte),
|
||||||
|
envelopes: make(map[common.Hash]*Envelope),
|
||||||
|
expirations: make(map[uint32]mapset.Set),
|
||||||
|
peers: make(map[*Peer]struct{}),
|
||||||
|
messageQueue: make(chan *Envelope, messageQueueLimit),
|
||||||
|
p2pMsgQueue: make(chan *Envelope, messageQueueLimit),
|
||||||
|
quit: make(chan struct{}),
|
||||||
|
syncAllowance: DefaultSyncAllowance,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MinPow returns the PoW value required by this node.
|
// MinPow returns the PoW value required by this node.
|
||||||
func (whisper *Whisper) MinPow() float64 {
|
func (whisper *Whisper) MinPow() float64 {
|
||||||
val, exist := whisper.settings.Load(minPowIdx)
|
val, exist := whisper.settings.Load(minPowIdx)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue