mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
whisperv6: remove duplicated code from api_test.go
This commit is contained in:
parent
2e9d1502d4
commit
373b95a833
2 changed files with 12 additions and 17 deletions
|
|
@ -23,8 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
|
func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
|
||||||
w := newDefaultWhisper()
|
w := New(nil)
|
||||||
w.filters = NewFilters(w)
|
|
||||||
|
|
||||||
keyID, err := w.GenerateSymKey()
|
keyID, err := w.GenerateSymKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,17 @@ func New(cfg *Config) *Whisper {
|
||||||
cfg = &DefaultConfig
|
cfg = &DefaultConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
whisper := newDefaultWhisper()
|
whisper := &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,
|
||||||
|
}
|
||||||
|
|
||||||
whisper.filters = NewFilters(whisper)
|
whisper.filters = NewFilters(whisper)
|
||||||
|
|
||||||
|
|
@ -123,20 +133,6 @@ 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