mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 19:36:44 +01:00
Add linter checks to GHA & Fix code to pass lints
Add linter checks to GHA & Fix code to pass lints. The linters added are: - whitespace: Tool for detection of leading and trailing whitespace - gosec: Inspects source code for security problems - gci: Gci control golang package import order and make it always deterministic - misspell: Finds commonly misspelled English words in comments - gomnd: An analyzer to detect magic numbers The file utils/utils.go is excluded from the checks of gomnd, as uses magic numbers through the code
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
ethCommon "github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
const batchNumBytesLen = 4
|
||||
|
||||
// Batch is a struct that represents Hermez network batch
|
||||
type Batch struct {
|
||||
BatchNum BatchNum `meddler:"batch_num"`
|
||||
@@ -33,7 +35,7 @@ func (bn BatchNum) Bytes() []byte {
|
||||
|
||||
// BatchNumFromBytes returns BatchNum from a []byte
|
||||
func BatchNumFromBytes(b []byte) (BatchNum, error) {
|
||||
if len(b) != 4 {
|
||||
if len(b) != batchNumBytesLen {
|
||||
return 0, fmt.Errorf("can not parse BatchNumFromBytes, bytes len %d, expected 4", len(b))
|
||||
}
|
||||
batchNum := binary.LittleEndian.Uint32(b[:4])
|
||||
|
||||
Reference in New Issue
Block a user