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 (
|
||||
"bytes"
|
||||
"crypto/ecdsa"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
mapset "github.com/deckarep/golang-set"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
|
||||
w := &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,
|
||||
}
|
||||
w := newDefaultWhisper()
|
||||
w.filters = NewFilters(w)
|
||||
|
||||
keyID, err := w.GenerateSymKey()
|
||||
|
|
|
|||
|
|
@ -96,17 +96,7 @@ func New(cfg *Config) *Whisper {
|
|||
cfg = &DefaultConfig
|
||||
}
|
||||
|
||||
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 := newDefaultWhisper()
|
||||
|
||||
whisper.filters = NewFilters(whisper)
|
||||
|
||||
|
|
@ -133,6 +123,20 @@ func New(cfg *Config) *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.
|
||||
func (whisper *Whisper) MinPow() float64 {
|
||||
val, exist := whisper.settings.Load(minPowIdx)
|
||||
|
|
|
|||
Loading…
Reference in a new issue