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. // any incoming messages, and sends only messages originated in this node.
func (api *PublicWhisperAPI) MakeLightClient(ctx context.Context) bool { func (api *PublicWhisperAPI) MakeLightClient(ctx context.Context) bool {
api.w.SetLightClientMode(true) api.w.SetLightClientMode(true)
return true return api.w.LightClientMode()
} }
// CancelLightClient cancels light client mode. // CancelLightClient cancels light client mode.
func (api *PublicWhisperAPI) CancelLightClient(ctx context.Context) bool { func (api *PublicWhisperAPI) CancelLightClient(ctx context.Context) bool {
api.w.SetLightClientMode(false) api.w.SetLightClientMode(false)
return true return !api.w.LightClientMode()
} }
//go:generate gencodec -type NewMessage -field-override newMessageOverride -out gen_newmessage_json.go //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{ var DefaultConfig = Config{
MaxMessageSize: DefaultMaxMessageSize, MaxMessageSize: DefaultMaxMessageSize,
MinimumAcceptedPOW: DefaultMinimumPoW, MinimumAcceptedPOW: DefaultMinimumPoW,
RestrictConnectionBetweenLightClients: false, RestrictConnectionBetweenLightClients: true,
} }

View file

@ -130,8 +130,8 @@ func (peer *Peer) handshake() error {
} }
} }
b, err := s.Bool() isRemotePeerLightNode, err := s.Bool()
if b && isLightNode && isRestrictedLightNodeConnection { if isRemotePeerLightNode && isLightNode && isRestrictedLightNodeConnection {
return fmt.Errorf("peer [%x] is useless: two light client communication restricted", peer.ID()) 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 return false
} }
v, ok := val.(bool) v, ok := val.(bool)
if !ok { return v && ok
return false
}
return v
} }
func (whisper *Whisper) notifyPeersAboutPowRequirementChange(pow float64) { func (whisper *Whisper) notifyPeersAboutPowRequirementChange(pow float64) {