Fixed code smells
This commit is contained in:
@@ -53,7 +53,7 @@ func (priv *PrivateKey) Sign(_ io.Reader, digest []byte, _ crypto.SignerOpts) (s
|
||||
|
||||
func (priv *PrivateKey) Public() crypto.PublicKey {
|
||||
p := &PublicKey{}
|
||||
newPublicKey(p, priv.pub[:])
|
||||
_, _ = newPublicKey(p, priv.pub[:])
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -118,7 +118,9 @@ func GenerateKey() (*PublicKey, *PrivateKey, error) {
|
||||
}
|
||||
|
||||
func generateKey(priv *PrivateKey) (*PrivateKey, error) {
|
||||
rand.Read(priv.seed[:])
|
||||
if _, err := rand.Read(priv.seed[:]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
precomputePrivateKey(priv)
|
||||
return priv, nil
|
||||
}
|
||||
|
||||
@@ -357,15 +357,6 @@ func (drv *companionDriver) wait(expect ...byte) ([]byte, error) {
|
||||
return wait.Wait()
|
||||
}
|
||||
|
||||
func bytesContains(b byte, slice []byte) bool {
|
||||
for _, v := range slice {
|
||||
if v == b {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (drv *companionDriver) handlePushFrame(b []byte) {
|
||||
if len(b) < 1 {
|
||||
return // illegal
|
||||
|
||||
@@ -10,10 +10,7 @@ import (
|
||||
"git.maze.io/go/ham/protocol/meshcore/crypto"
|
||||
)
|
||||
|
||||
var (
|
||||
zeroTime time.Time
|
||||
zeroPositionBytes = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
)
|
||||
var zeroPositionBytes = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
|
||||
type Payload interface {
|
||||
fmt.Stringer
|
||||
|
||||
@@ -47,10 +47,6 @@ func decodeTime(b []byte) time.Time {
|
||||
return time.Unix(int64(binary.LittleEndian.Uint32(b)), 0).UTC()
|
||||
}
|
||||
|
||||
func encodeFrequency(b []byte, f float64) {
|
||||
binary.LittleEndian.PutUint32(b, uint32(f*1e3))
|
||||
}
|
||||
|
||||
func decodeFrequency(b []byte) float64 {
|
||||
return float64(int64(binary.LittleEndian.Uint32(b))) / 1e3
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user