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

@@ -4,8 +4,8 @@ import (
"github.com/hermeznetwork/hermez-node/common"
)
// Proof TBD this type will be got from the proof server
type Proof struct {
// TBD this type will be got from the proof server
}
// BatchInfo contans the Batch information
@@ -58,6 +58,7 @@ type BatchQueue struct {
queue []*BatchInfo
}
// NewBatchQueue returns a new *BatchQueue
func NewBatchQueue() *BatchQueue {
return &BatchQueue{
queue: []*BatchInfo{},

View File

@@ -14,8 +14,8 @@ import (
"github.com/iden3/go-merkletree/db/memory"
)
// CoordinatorConfig contains the Coordinator configuration
type CoordinatorConfig struct {
// Config contains the Coordinator configuration
type Config struct {
ForgerAddress ethCommon.Address
LoopInterval time.Duration
}
@@ -29,7 +29,7 @@ type Coordinator struct {
forging bool
isForgeSeq bool // WIP just for testing while implementing
config CoordinatorConfig
config Config
batchNum common.BatchNum
batchQueue *BatchQueue
@@ -45,7 +45,7 @@ type Coordinator struct {
}
// NewCoordinator creates a new Coordinator
func NewCoordinator(conf CoordinatorConfig,
func NewCoordinator(conf Config,
hdb *historydb.HistoryDB,
txsel *txselector.TxSelector,
bb *batchbuilder.BatchBuilder,
@@ -61,6 +61,7 @@ func NewCoordinator(conf CoordinatorConfig,
return &c
}
// Stop stops the Coordinator
func (c *Coordinator) Stop() {
log.Info("Stopping Coordinator")
c.stopch <- true

View File

@@ -46,7 +46,7 @@ func newTestModules(t *testing.T) (*txselector.TxSelector, *batchbuilder.BatchBu
func TestCoordinator(t *testing.T) {
txsel, bb := newTestModules(t)
conf := CoordinatorConfig{
conf := Config{
LoopInterval: 100 * time.Millisecond,
}
hdb := &historydb.HistoryDB{}

View File

@@ -2,23 +2,29 @@ package coordinator
import "github.com/hermeznetwork/hermez-node/common"
// ServerProofInfo contains the data related to a ServerProof
type ServerProofInfo struct {
// TODO
Available bool
}
// CalculateProof sends the *common.ZKInputs to the ServerProof to compute the
// Proof
func (p *ServerProofInfo) CalculateProof(zkInputs *common.ZKInputs) error {
return nil
}
// GetProof retreives the Proof from the ServerProof
func (p *ServerProofInfo) GetProof() (*Proof, error) {
return nil, nil
}
// ServerProofPool contains the multiple ServerProofInfo
type ServerProofPool struct {
// pool []ServerProofInfo
}
// GetNextAvailable returns the available ServerProofInfo
func (p *ServerProofPool) GetNextAvailable() (*ServerProofInfo, error) {
return nil, nil
}