whisper: fix megacheck warnings (#14925)
* whisper: fix megacheck warnings * whisper/whisperv5: regenerate json codec to fix unused override type
This commit is contained in:
parent
374c49e0ac
commit
d375193797
@ -104,7 +104,7 @@ func (s *WMailServer) Archive(env *whisper.Envelope) {
|
|||||||
|
|
||||||
func (s *WMailServer) DeliverMail(peer *whisper.Peer, request *whisper.Envelope) {
|
func (s *WMailServer) DeliverMail(peer *whisper.Peer, request *whisper.Envelope) {
|
||||||
if peer == nil {
|
if peer == nil {
|
||||||
log.Error(fmt.Sprint("Whisper peer is nil"))
|
log.Error("Whisper peer is nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ func singleRequest(t *testing.T, server *WMailServer, env *whisper.Envelope, p *
|
|||||||
src[0]++
|
src[0]++
|
||||||
ok, lower, upper, topic = server.validateRequest(src, request)
|
ok, lower, upper, topic = server.validateRequest(src, request)
|
||||||
if ok {
|
if ok {
|
||||||
t.Fatalf("request validation false positive, seed: %d.", seed)
|
t.Fatalf("request validation false positive, seed: %d (lower: %d, upper: %d).", seed, lower, upper)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,15 +377,6 @@ func (w *whisperFilter) retrieve() (messages []WhisperMessage) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// activity returns the last time instance when client requests were executed on
|
|
||||||
// the filter.
|
|
||||||
func (w *whisperFilter) activity() time.Time {
|
|
||||||
w.lock.RLock()
|
|
||||||
defer w.lock.RUnlock()
|
|
||||||
|
|
||||||
return w.update
|
|
||||||
}
|
|
||||||
|
|
||||||
// newWhisperFilter creates a new serialized, poll based whisper topic filter.
|
// newWhisperFilter creates a new serialized, poll based whisper topic filter.
|
||||||
func newWhisperFilter(id hexutil.Uint, ref *Whisper) *whisperFilter {
|
func newWhisperFilter(id hexutil.Uint, ref *Whisper) *whisperFilter {
|
||||||
return &whisperFilter{
|
return &whisperFilter{
|
||||||
|
@ -173,7 +173,7 @@ func (self *Whisper) Send(envelope *Envelope) error {
|
|||||||
// Start implements node.Service, starting the background data propagation thread
|
// Start implements node.Service, starting the background data propagation thread
|
||||||
// of the Whisper protocol.
|
// of the Whisper protocol.
|
||||||
func (self *Whisper) Start(*p2p.Server) error {
|
func (self *Whisper) Start(*p2p.Server) error {
|
||||||
log.Info(fmt.Sprint("Whisper started"))
|
log.Info("Whisper started")
|
||||||
go self.update()
|
go self.update()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ func (self *Whisper) Start(*p2p.Server) error {
|
|||||||
// of the Whisper protocol.
|
// of the Whisper protocol.
|
||||||
func (self *Whisper) Stop() error {
|
func (self *Whisper) Stop() error {
|
||||||
close(self.quit)
|
close(self.quit)
|
||||||
log.Info(fmt.Sprint("Whisper stopped"))
|
log.Info("Whisper stopped")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ = (*criteriaOverride)(nil)
|
||||||
|
|
||||||
func (c Criteria) MarshalJSON() ([]byte, error) {
|
func (c Criteria) MarshalJSON() ([]byte, error) {
|
||||||
type Criteria struct {
|
type Criteria struct {
|
||||||
SymKeyID string `json:"symKeyID"`
|
SymKeyID string `json:"symKeyID"`
|
||||||
|
@ -8,6 +8,8 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ = (*messageOverride)(nil)
|
||||||
|
|
||||||
func (m Message) MarshalJSON() ([]byte, error) {
|
func (m Message) MarshalJSON() ([]byte, error) {
|
||||||
type Message struct {
|
type Message struct {
|
||||||
Sig hexutil.Bytes `json:"sig,omitempty"`
|
Sig hexutil.Bytes `json:"sig,omitempty"`
|
||||||
|
@ -8,6 +8,8 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ = (*newMessageOverride)(nil)
|
||||||
|
|
||||||
func (n NewMessage) MarshalJSON() ([]byte, error) {
|
func (n NewMessage) MarshalJSON() ([]byte, error) {
|
||||||
type NewMessage struct {
|
type NewMessage struct {
|
||||||
SymKeyID string `json:"symKeyID"`
|
SymKeyID string `json:"symKeyID"`
|
||||||
|
@ -25,11 +25,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func copyFromBuf(dst []byte, src []byte, beg int) int {
|
|
||||||
copy(dst, src[beg:])
|
|
||||||
return beg + len(dst)
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateMessageParams() (*MessageParams, error) {
|
func generateMessageParams() (*MessageParams, error) {
|
||||||
// set all the parameters except p.Dst and p.Padding
|
// set all the parameters except p.Dst and p.Padding
|
||||||
|
|
||||||
@ -158,7 +153,7 @@ func TestMessageWrap(t *testing.T) {
|
|||||||
params.TTL = 1000000
|
params.TTL = 1000000
|
||||||
params.WorkTime = 1
|
params.WorkTime = 1
|
||||||
params.PoW = 10000000.0
|
params.PoW = 10000000.0
|
||||||
env, err = msg2.Wrap(params)
|
_, err = msg2.Wrap(params)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("unexpectedly reached the PoW target with seed %d.", seed)
|
t.Fatalf("unexpectedly reached the PoW target with seed %d.", seed)
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ func TestWhisperSymKeyManagement(t *testing.T) {
|
|||||||
|
|
||||||
randomKey = make([]byte, aesKeyLength+1)
|
randomKey = make([]byte, aesKeyLength+1)
|
||||||
mrand.Read(randomKey)
|
mrand.Read(randomKey)
|
||||||
id1, err = w.AddSymKeyDirect(randomKey)
|
_, err = w.AddSymKeyDirect(randomKey)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("added the key with wrong size, seed %d.", seed)
|
t.Fatalf("added the key with wrong size, seed %d.", seed)
|
||||||
}
|
}
|
||||||
@ -541,6 +541,9 @@ func TestCustomization(t *testing.T) {
|
|||||||
const smallPoW = 0.00001
|
const smallPoW = 0.00001
|
||||||
|
|
||||||
f, err := generateFilter(t, true)
|
f, err := generateFilter(t, true)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||||
|
}
|
||||||
params, err := generateMessageParams()
|
params, err := generateMessageParams()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||||
@ -607,6 +610,9 @@ func TestCustomization(t *testing.T) {
|
|||||||
|
|
||||||
// check w.messages()
|
// check w.messages()
|
||||||
id, err := w.Subscribe(f)
|
id, err := w.Subscribe(f)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed subscribe with seed %d: %s.", seed, err)
|
||||||
|
}
|
||||||
time.Sleep(5 * time.Millisecond)
|
time.Sleep(5 * time.Millisecond)
|
||||||
mail := f.Retrieve()
|
mail := f.Retrieve()
|
||||||
if len(mail) > 0 {
|
if len(mail) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user