whisper: minor fixes

This commit is contained in:
b00ris 2018-06-07 13:46:09 +03:00
parent ca0eb7997e
commit 2e9d3bc0f7
No known key found for this signature in database
GPG key ID: 2F73E159EB73232C
4 changed files with 6 additions and 9 deletions

View file

@ -196,13 +196,13 @@ func (api *PublicWhisperAPI) DeleteSymKey(ctx context.Context, id string) bool {
// any incoming messages, and sends only messages originated in this node.
func (api *PublicWhisperAPI) MakeLightClient(ctx context.Context) bool {
api.w.SetLightClientMode(true)
return true
return api.w.LightClientMode()
}
// CancelLightClient cancels light client mode.
func (api *PublicWhisperAPI) CancelLightClient(ctx context.Context) bool {
api.w.SetLightClientMode(false)
return true
return !api.w.LightClientMode()
}
//go:generate gencodec -type NewMessage -field-override newMessageOverride -out gen_newmessage_json.go

View file

@ -27,5 +27,5 @@ type Config struct {
var DefaultConfig = Config{
MaxMessageSize: DefaultMaxMessageSize,
MinimumAcceptedPOW: DefaultMinimumPoW,
RestrictConnectionBetweenLightClients: false,
RestrictConnectionBetweenLightClients: true,
}

View file

@ -130,8 +130,8 @@ func (peer *Peer) handshake() error {
}
}
b, err := s.Bool()
if b && isLightNode && isRestrictedLightNodeConnection {
isRemotePeerLightNode, err := s.Bool()
if isRemotePeerLightNode && isLightNode && isRestrictedLightNodeConnection {
return fmt.Errorf("peer [%x] is useless: two light client communication restricted", peer.ID())
}

View file

@ -302,10 +302,7 @@ func (whisper *Whisper) LightClientModeConnectionRestricted() bool {
return false
}
v, ok := val.(bool)
if !ok {
return false
}
return v
return v && ok
}
func (whisper *Whisper) notifyPeersAboutPowRequirementChange(pow float64) {