Add lint checks: gofmt, goimports, golint

- gofmt - Gofmt checks whether code was gofmt-ed. By default this tool runs
  with -s option to check for code simplification
- goimports - Goimports does everything that gofmt does. Additionally it checks
  unused imports
- golint - Golint differs from gofmt. Gofmt reformats Go source code, whereas
  golint prints out style mistakes
    - checks the uncommented exported functions & types

Update the code to fix the lint checks.
This commit is contained in:
arnaucube
2020-08-31 12:26:35 +02:00
parent 3bd91ec736
commit cbbcb65c8c
21 changed files with 98 additions and 51 deletions

View File

@@ -13,6 +13,7 @@ import (
)
const (
// NLEAFELEMS is the number of elements for a leaf
NLEAFELEMS = 4
// maxNonceValue is the maximum value that the Account.Nonce can have (40 bits: maxNonceValue=2**40-1)
maxNonceValue = 0xffffffffff

View File

@@ -6,6 +6,7 @@ import (
"github.com/iden3/go-merkletree"
)
// ExitInfo represents the ExitTree Leaf data
type ExitInfo struct {
AccountIdx Idx
MerkleProof *merkletree.CircomVerifierProof

View File

@@ -4,8 +4,9 @@ package common
// to incentivaise the materialization of it
type Fee float64
// RecommendedFee is the recommended fee to pay in USD per transaction set by the coordinator
// according to the tx type (if the tx requires to create an account and register, only register or he account already esists)
// RecommendedFee is the recommended fee to pay in USD per transaction set by
// the coordinator according to the tx type (if the tx requires to create an
// account and register, only register or he account already esists)
type RecommendedFee struct {
ExistingAccount float64
CreatesAccount float64
@@ -15,7 +16,9 @@ type RecommendedFee struct {
// FeeSelector is used to select a percentage from the FeePlan.
type FeeSelector uint8
// MAXFEEPLAN is the maximum value of the FeePlan
const MAXFEEPLAN = 256
// FeePlan represents the fee model, a position in the array indicates the percentage of tokens paid in concept of fee for a transaction
// FeePlan represents the fee model, a position in the array indicates the
// percentage of tokens paid in concept of fee for a transaction
var FeePlan = [MAXFEEPLAN]float64{}

View File

@@ -25,6 +25,7 @@ type L1Tx struct {
Type TxType `meddler:"tx_type"`
}
// Tx returns a *Tx from the L1Tx
func (tx *L1Tx) Tx() *Tx {
return &Tx{
TxID: tx.TxID,

View File

@@ -18,6 +18,7 @@ type L2Tx struct {
Type TxType `meddler:"tx_type"`
}
// Tx returns a *Tx from the L2Tx
func (tx *L2Tx) Tx() *Tx {
return &Tx{
TxID: tx.TxID,

View File

@@ -172,6 +172,7 @@ func (tx *PoolL2Tx) VerifySignature(pk *babyjub.PublicKey) bool {
return pk.VerifyPoseidon(h, tx.Signature)
}
// L2Tx returns a *L2Tx from the PoolL2Tx
func (tx *PoolL2Tx) L2Tx() *L2Tx {
return &L2Tx{
TxID: tx.TxID,
@@ -185,6 +186,7 @@ func (tx *PoolL2Tx) L2Tx() *L2Tx {
}
}
// Tx returns a *Tx from the PoolL2Tx
func (tx *PoolL2Tx) Tx() *Tx {
return &Tx{
TxID: tx.TxID,
@@ -197,6 +199,7 @@ func (tx *PoolL2Tx) Tx() *Tx {
}
}
// PoolL2TxsToL2Txs returns an array of []*L2Tx from an array of []*PoolL2Tx
func PoolL2TxsToL2Txs(txs []*PoolL2Tx) []*L2Tx {
var r []*L2Tx
for _, tx := range txs {

View File

@@ -6,6 +6,7 @@ import (
eth "github.com/ethereum/go-ethereum/common"
)
// RollupVars contain the Rollup smart contract variables
type RollupVars struct {
EthBlockNum uint64
ForgeL1Timeout *big.Int
@@ -15,6 +16,7 @@ type RollupVars struct {
Governance eth.Address
}
// AuctionVars contain the Auction smart contract variables
type AuctionVars struct {
EthBlockNum uint64
SlotDeadline uint
@@ -28,8 +30,10 @@ type AuctionVars struct {
AllocationRatio AllocationRatio
}
// MinBidSlots TODO
type MinBidSlots [6]uint
// AllocationRatio TODO
type AllocationRatio struct {
Donation uint
Burn uint

View File

@@ -4,6 +4,8 @@ import (
"math/big"
)
// ZKInputs represents the inputs that will be used to generate the zkSNARK
// proof
type ZKInputs struct {
InitialIdx uint64
OldStRoot Hash
@@ -19,7 +21,7 @@ type ZKInputs struct {
TxData []*big.Int
FromIdx []uint64
ToIdX []uint64
ToIdX []uint64 //nolint:golint
ToAx []*big.Int
ToAy []*big.Int
ToEthAddr []*big.Int
@@ -55,10 +57,7 @@ type ZKInputs struct {
OldValue2 []*big.Int
}
// CallDataForge TBD
type CallDataForge struct {
// TBD
}
type ExitTreeLeaf struct {
// TBD
}