diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml new file mode 100644 index 00000000..021b4c41 --- /dev/null +++ b/.github/workflows/golangci-lint.yaml @@ -0,0 +1,55 @@ +name: golangci-lint +on: + push: + branches: + - master + - main + pull_request: + +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.19' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Require: The version of golangci-lint to use. + # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. + # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. + version: v1.55.2 + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + # + # Note: By default, the `.golangci.yml` file should be at the root of the repository. + # The location of the configuration file can be changed by using `--config=` + # args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0 + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + # Optional: if set to true, then all caching functionality will be completely disabled, + # takes precedence over all other caching options. + # skip-cache: true + + # Optional: if set to true, then the action won't cache or restore ~/go/pkg. + # skip-pkg-cache: true + + # Optional: if set to true, then the action won't cache or restore ~/.cache/go-build. + # skip-build-cache: true + + # Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'. + # install-mode: "goinstall" diff --git a/.golangci.yml b/.golangci.yml index 6a28ffa7..94f76b5c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,7 +6,6 @@ run: linters: disable-all: true enable: - - depguard - dogsled - exportloopref - errcheck diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da5466b5..98a42f5f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,8 +20,6 @@ repos: # args: [-over=15] - id: validate-toml - id: no-go-testing - - id: golangci-lint - args: [--timeout,10m] # - id: go-critic # - id: go-unit-tests - id: go-build diff --git a/core/block_enqueue.go b/core/block_enqueue.go index 27d27ca8..25049a3b 100644 --- a/core/block_enqueue.go +++ b/core/block_enqueue.go @@ -310,24 +310,23 @@ func GenerateDefaultEnqueueFunction(db *gorm.DB, cfg config.IndexConfig, client config.Log.Debugf("Block %d already indexed, skipping", currBlock) currBlock++ continue - } else { - config.Log.Debugf("Block %d needs indexing, adding to queue", currBlock) - blockChan <- &EnqueueData{ - Height: currBlock, - IndexBlockEvents: cfg.Base.BlockEventIndexingEnabled && !block.BlockEventsIndexed, - IndexTransactions: cfg.Base.TransactionIndexingEnabled && !block.TxIndexed, - } - - delete(blocksInDB, currBlock) + } + config.Log.Debugf("Block %d needs indexing, adding to queue", currBlock) + blockChan <- &EnqueueData{ + Height: currBlock, + IndexBlockEvents: cfg.Base.BlockEventIndexingEnabled && !block.BlockEventsIndexed, + IndexTransactions: cfg.Base.TransactionIndexingEnabled && !block.TxIndexed, + } - currBlock++ + delete(blocksInDB, currBlock) - if cfg.Base.Throttling != 0 { - time.Sleep(time.Second * time.Duration(cfg.Base.Throttling)) - } + currBlock++ - continue + if cfg.Base.Throttling != 0 { + time.Sleep(time.Second * time.Duration(cfg.Base.Throttling)) } + + continue } // Add the new block to the queue diff --git a/core/tx.go b/core/tx.go index 4f89aa83..8b5f14e8 100644 --- a/core/tx.go +++ b/core/tx.go @@ -258,7 +258,7 @@ func ProcessTx(db *gorm.DB, tx txtypes.MergedTx) (txDBWapper dbTypes.TxDBWrapper txTime, err = time.Parse(time.RFC3339, tx.TxResponse.TimeStamp) if err != nil { config.Log.Error("Error parsing tx timestamp.", err) - return + return txDBWapper, txTime, err } code := tx.TxResponse.Code diff --git a/db/db.go b/db/db.go index 3477044c..8912770e 100644 --- a/db/db.go +++ b/db/db.go @@ -528,7 +528,8 @@ func indexMessageEventAttributeKeys(db *gorm.DB, txs []TxDBWrapper) (map[string] func UpsertDenoms(db *gorm.DB, denoms []DenomDBWrapper) error { return db.Transaction(func(dbTransaction *gorm.DB) error { - for _, denom := range denoms { + for i := range denoms { + denom := denoms[i] if err := dbTransaction.Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "base"}}, DoUpdates: clause.AssignmentColumns([]string{"symbol", "name"}), @@ -536,7 +537,8 @@ func UpsertDenoms(db *gorm.DB, denoms []DenomDBWrapper) error { return err } - for _, denomUnit := range denom.DenomUnits { + for i := range denom.DenomUnits { + denomUnit := denom.DenomUnits[i] denomUnit.DenomUnit.Denom = denom.Denom if err := dbTransaction.Clauses(clause.OnConflict{ diff --git a/docs/README.md b/docs/README.md index ae503365..5718a0b5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,4 +2,4 @@ The documentation found here is in-repo documentation intended for use in documenting and explaining workflows. -You may find more information in the [Cosmos Indexer Wiki](https://github.com/DefiantLabs/cosmos-indexer/wiki). \ No newline at end of file +You may find more information in the [Cosmos Indexer Wiki](https://github.com/DefiantLabs/cosmos-indexer/wiki). diff --git a/docs/application-workflow/README.md b/docs/application-workflow/README.md index 4e3ec77d..819ebd88 100644 --- a/docs/application-workflow/README.md +++ b/docs/application-workflow/README.md @@ -32,4 +32,4 @@ The parser worker is responsible for taking the raw, on-chain data from the RPC ## DB Worker -The database worker is responsible for inserting the parsed application types into the database. It is responsible for building up the data associations according to the data schema defined by the application. \ No newline at end of file +The database worker is responsible for inserting the parsed application types into the database. It is responsible for building up the data associations according to the data schema defined by the application.