diff --git a/whisper/whisperv6/api.go b/whisper/whisperv6/api.go index c4d1a9217d..7e0dab7442 100644 --- a/whisper/whisperv6/api.go +++ b/whisper/whisperv6/api.go @@ -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 diff --git a/whisper/whisperv6/config.go b/whisper/whisperv6/config.go index cb7d53f8aa..38eb9551cc 100644 --- a/whisper/whisperv6/config.go +++ b/whisper/whisperv6/config.go @@ -27,5 +27,5 @@ type Config struct { var DefaultConfig = Config{ MaxMessageSize: DefaultMaxMessageSize, MinimumAcceptedPOW: DefaultMinimumPoW, - RestrictConnectionBetweenLightClients: false, + RestrictConnectionBetweenLightClients: true, } diff --git a/whisper/whisperv6/peer.go b/whisper/whisperv6/peer.go index 08b47e8d9a..dfdb046aa6 100644 --- a/whisper/whisperv6/peer.go +++ b/whisper/whisperv6/peer.go @@ -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()) } diff --git a/whisper/whisperv6/whisper.go b/whisper/whisperv6/whisper.go index 9c7611a16b..64df7c3d42 100644 --- a/whisper/whisperv6/whisper.go +++ b/whisper/whisperv6/whisper.go @@ -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) {