mobile: fixed lint warnings

This commit is contained in:
Eugene Valeyev 2018-01-15 13:10:10 +03:00
parent f22a3e9451
commit 9b03dae499
2 changed files with 17 additions and 29 deletions

View file

@ -36,8 +36,7 @@ func NewWhisperClient(rawurl string) (client *WhisperClient, _ error) {
// GetVersion returns the Whisper sub-protocol version. // GetVersion returns the Whisper sub-protocol version.
func (wc *WhisperClient) GetVersion(ctx *Context) (version string, _ error) { func (wc *WhisperClient) GetVersion(ctx *Context) (version string, _ error) {
rawVersion, err := wc.client.Version(ctx.context) return wc.client.Version(ctx.context)
return string(rawVersion), err
} }
// Info returns diagnostic information about the whisper node. // Info returns diagnostic information about the whisper node.
@ -72,27 +71,23 @@ func (wc *WhisperClient) MarkTrustedPeer(ctx *Context, enode string) error {
// NewKeyPair generates a new public and private key pair for message decryption and encryption. // NewKeyPair generates a new public and private key pair for message decryption and encryption.
// It returns an identifier that can be used to refer to the key. // It returns an identifier that can be used to refer to the key.
func (wc *WhisperClient) NewKeyPair(ctx *Context) (string, error) { func (wc *WhisperClient) NewKeyPair(ctx *Context) (string, error) {
rawNewKeyPair, err := wc.client.NewKeyPair(ctx.context) return wc.client.NewKeyPair(ctx.context)
return string(rawNewKeyPair), err
} }
// AddPrivateKey stored the key pair, and returns its ID. // AddPrivateKey stored the key pair, and returns its ID.
func (wc *WhisperClient) AddPrivateKey(ctx *Context, key []byte) (string, error) { func (wc *WhisperClient) AddPrivateKey(ctx *Context, key []byte) (string, error) {
rawAddPrivateKey, err := wc.client.AddPrivateKey(ctx.context, key) return wc.client.AddPrivateKey(ctx.context, key)
return string(rawAddPrivateKey), err
} }
// DeleteKeyPair delete the specifies key. // DeleteKeyPair delete the specifies key.
func (wc *WhisperClient) DeleteKeyPair(ctx *Context, id string) (string, error) { func (wc *WhisperClient) DeleteKeyPair(ctx *Context, id string) (string, error) {
rawDeletePrivateKey, err := wc.client.DeleteKeyPair(ctx.context, id) return wc.client.DeleteKeyPair(ctx.context, id)
return string(rawDeletePrivateKey), err
} }
// HasKeyPair returns an indication if the node has a private key or // HasKeyPair returns an indication if the node has a private key or
// key pair matching the given ID. // key pair matching the given ID.
func (wc *WhisperClient) HasKeyPair(ctx *Context, id string) (bool, error) { func (wc *WhisperClient) HasKeyPair(ctx *Context, id string) (bool, error) {
rawHasKeyPair, err := wc.client.HasKeyPair(ctx.context, id) return wc.client.HasKeyPair(ctx.context, id)
return bool(rawHasKeyPair), err
} }
// GetPublicKey return the public key for a key ID. // GetPublicKey return the public key for a key ID.
@ -108,26 +103,22 @@ func (wc *WhisperClient) GetPrivateKey(ctx *Context, id string) ([]byte, error)
// NewSymmetricKey generates a random symmetric key and returns its identifier. // NewSymmetricKey generates a random symmetric key and returns its identifier.
// Can be used encrypting and decrypting messages where the key is known to both parties. // Can be used encrypting and decrypting messages where the key is known to both parties.
func (wc *WhisperClient) NewSymmetricKey(ctx *Context) (string, error) { func (wc *WhisperClient) NewSymmetricKey(ctx *Context) (string, error) {
rawNewSymmetricKey, err := wc.client.NewSymmetricKey(ctx.context) return wc.client.NewSymmetricKey(ctx.context)
return string(rawNewSymmetricKey), err
} }
// AddSymmetricKey stores the key, and returns its identifier. // AddSymmetricKey stores the key, and returns its identifier.
func (wc *WhisperClient) AddSymmetricKey(ctx *Context, key []byte) (string, error) { func (wc *WhisperClient) AddSymmetricKey(ctx *Context, key []byte) (string, error) {
rawAddSymmetricKey, err := wc.client.AddSymmetricKey(ctx.context, key) return wc.client.AddSymmetricKey(ctx.context, key)
return string(rawAddSymmetricKey), err
} }
// GenerateSymmetricKeyFromPassword generates the key from password, stores it, and returns its identifier. // GenerateSymmetricKeyFromPassword generates the key from password, stores it, and returns its identifier.
func (wc *WhisperClient) GenerateSymmetricKeyFromPassword(ctx *Context, passwd string) (string, error) { func (wc *WhisperClient) GenerateSymmetricKeyFromPassword(ctx *Context, passwd string) (string, error) {
rawSymKeyID, err := wc.client.GenerateSymmetricKeyFromPassword(ctx.context, passwd) return wc.client.GenerateSymmetricKeyFromPassword(ctx.context, passwd)
return string(rawSymKeyID), err
} }
// HasSymmetricKey returns an indication if the key associated with the given id is stored in the node. // HasSymmetricKey returns an indication if the key associated with the given id is stored in the node.
func (wc *WhisperClient) HasSymmetricKey(ctx *Context, id string) (bool, error) { func (wc *WhisperClient) HasSymmetricKey(ctx *Context, id string) (bool, error) {
rawHasSymmetricKey, err := wc.client.HasSymmetricKey(ctx.context, id) return wc.client.HasSymmetricKey(ctx.context, id)
return bool(rawHasSymmetricKey), err
} }
// GetSymmetricKey returns the symmetric key associated with the given identifier. // GetSymmetricKey returns the symmetric key associated with the given identifier.
@ -182,8 +173,7 @@ func (wc *WhisperClient) SubscribeMessages(ctx *Context, criteria *Criteria, han
// for new messages (see FilterMessages) that satisfy the given criteria. A filter can // for new messages (see FilterMessages) that satisfy the given criteria. A filter can
// timeout when it was polled for in whisper.filterTimeout. // timeout when it was polled for in whisper.filterTimeout.
func (wc *WhisperClient) NewMessageFilter(ctx *Context, criteria *Criteria) (string, error) { func (wc *WhisperClient) NewMessageFilter(ctx *Context, criteria *Criteria) (string, error) {
rawNewMessageFilter, err := wc.client.NewMessageFilter(ctx.context, *criteria.criteria) return wc.client.NewMessageFilter(ctx.context, *criteria.criteria)
return string(rawNewMessageFilter), err
} }
// DeleteMessageFilter removes the filter associated with the given id. // DeleteMessageFilter removes the filter associated with the given id.
@ -199,8 +189,6 @@ func (wc *WhisperClient) GetFilterMessages(ctx *Context, id string) (*Messages,
return nil, err return nil, err
} }
res := make([]*whisper.Message, len(rawFilterMessages)) res := make([]*whisper.Message, len(rawFilterMessages))
for i := range rawFilterMessages { copy(res, rawFilterMessages)
res[i] = rawFilterMessages[i]
}
return &Messages{res}, nil return &Messages{res}, nil
} }

View file

@ -385,12 +385,12 @@ func (nm *NewMessage) GetPublicKey() []byte { return nm.newMessage.Pu
func (nm *NewMessage) SetPublicKey(publicKey []byte) { nm.newMessage.PublicKey = publicKey } func (nm *NewMessage) SetPublicKey(publicKey []byte) { nm.newMessage.PublicKey = publicKey }
func (nm *NewMessage) GetSig() string { return nm.newMessage.Sig } func (nm *NewMessage) GetSig() string { return nm.newMessage.Sig }
func (nm *NewMessage) SetSig(sig string) { nm.newMessage.Sig = sig } func (nm *NewMessage) SetSig(sig string) { nm.newMessage.Sig = sig }
func (nm *NewMessage) GetTTL() int32 { return int32(nm.newMessage.TTL) } func (nm *NewMessage) GetTTL() int64 { return int64(nm.newMessage.TTL) }
func (nm *NewMessage) SetTTL(ttl int32) { nm.newMessage.TTL = uint32(ttl) } func (nm *NewMessage) SetTTL(ttl int64) { nm.newMessage.TTL = uint32(ttl) }
func (nm *NewMessage) GetPayload() []byte { return nm.newMessage.Payload } func (nm *NewMessage) GetPayload() []byte { return nm.newMessage.Payload }
func (nm *NewMessage) SetPayload(payload []byte) { nm.newMessage.Payload = payload } func (nm *NewMessage) SetPayload(payload []byte) { nm.newMessage.Payload = payload }
func (nm *NewMessage) GetPowTime() int32 { return int32(nm.newMessage.PowTime) } func (nm *NewMessage) GetPowTime() int64 { return int64(nm.newMessage.PowTime) }
func (nm *NewMessage) SetPowTime(powTime int32) { nm.newMessage.PowTime = uint32(powTime) } func (nm *NewMessage) SetPowTime(powTime int64) { nm.newMessage.PowTime = uint32(powTime) }
func (nm *NewMessage) GetPowTarget() float64 { return nm.newMessage.PowTarget } func (nm *NewMessage) GetPowTarget() float64 { return nm.newMessage.PowTarget }
func (nm *NewMessage) SetPowTarget(powTarget float64) { nm.newMessage.PowTarget = powTarget } func (nm *NewMessage) SetPowTarget(powTarget float64) { nm.newMessage.PowTarget = powTarget }
func (nm *NewMessage) GetTargetPeer() string { return nm.newMessage.TargetPeer } func (nm *NewMessage) GetTargetPeer() string { return nm.newMessage.TargetPeer }
@ -404,8 +404,8 @@ type Message struct {
} }
func (m *Message) GetSig() []byte { return m.message.Sig } func (m *Message) GetSig() []byte { return m.message.Sig }
func (m *Message) GetTTL() int32 { return int32(m.message.TTL) } func (m *Message) GetTTL() int64 { return int64(m.message.TTL) }
func (m *Message) GetTimestamp() int32 { return int32(m.message.Timestamp) } func (m *Message) GetTimestamp() int64 { return int64(m.message.Timestamp) }
func (m *Message) GetPayload() []byte { return m.message.Payload } func (m *Message) GetPayload() []byte { return m.message.Payload }
func (m *Message) GetPoW() float64 { return m.message.PoW } func (m *Message) GetPoW() float64 { return m.message.PoW }
func (m *Message) GetHash() []byte { return m.message.Hash } func (m *Message) GetHash() []byte { return m.message.Hash }