diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..df9c07a --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,26 @@ +name: golangci-lint +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.20' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.54.2 + # --exclude=unused-parameter was added due to methods with TODO implementation + args: --exclude=unused-parameter --timeout=3m diff --git a/internal/tezos/blocklistener.go b/internal/tezos/blocklistener.go index ad0c30b..af63808 100644 --- a/internal/tezos/blocklistener.go +++ b/internal/tezos/blocklistener.go @@ -115,10 +115,8 @@ func (bl *blockListener) listenLoop() { } else { log.L(bl.ctx).Debugf("monitor: %s", err.Error()) - select { - case <-bl.ctx.Done(): - return - } + <-bl.ctx.Done() + return } continue } diff --git a/internal/tezos/event_listener.go b/internal/tezos/event_listener.go index 61c72cb..539b780 100644 --- a/internal/tezos/event_listener.go +++ b/internal/tezos/event_listener.go @@ -1,29 +1,7 @@ package tezos -import ( - "sync" - - "github.com/hyperledger/firefly-common/pkg/fftypes" -) - -// listenerConfig is the configuration parsed from generic FFCAPI connector framework JSON, into our Tezos specific options -type listenerConfig struct { - name string - fromBlock string - // options *listenerOptions - // filters []*eventFilter - signature string -} - // listener is the state we hold in memory for each individual listener that has been added type listener struct { - id *fftypes.UUID - c *tezosConnector - es *eventStream - hwmMux sync.Mutex // Protects checkpoint of an individual listener. May hold ES lock when taking this, must NOT attempt to obtain ES lock while holding this hwmBlock int64 - config listenerConfig - removed bool - catchup bool catchupLoopDone chan struct{} } diff --git a/internal/tezos/event_stream.go b/internal/tezos/event_stream.go index 87a4be0..db33517 100644 --- a/internal/tezos/event_stream.go +++ b/internal/tezos/event_stream.go @@ -2,7 +2,6 @@ package tezos import ( "context" - "sync" "github.com/hyperledger/firefly-common/pkg/fftypes" "github.com/hyperledger/firefly-transaction-manager/pkg/ffcapi" @@ -14,8 +13,6 @@ type eventStream struct { ctx context.Context c *tezosConnector events chan<- *ffcapi.ListenerEvent - mux sync.Mutex - updateCount int listeners map[fftypes.UUID]*listener headBlock int64 streamLoopDone chan struct{} @@ -31,10 +28,6 @@ func (es *eventStream) startEventListener(l *listener) { // TODO: impl } -func (es *eventStream) removeEventListener(listenerID *fftypes.UUID) { - // TODO: impl -} - func (es *eventStream) streamLoop() { defer close(es.streamLoopDone) @@ -57,6 +50,8 @@ func (es *eventStream) streamLoop() { // leadGroupCatchup is called whenever the steam loop restarts, to see how far it is behind the head of the // chain and if it's a way behind then we catch up all this head group as one set (rather than with individual // catchup routines as is the case if one listener starts a way behind the pack) +// +//nolint:unparam func (es *eventStream) leadGroupCatchup() bool { // For API status, we keep a track of whether we're in catchup mode or not diff --git a/internal/tezos/send_transaction.go b/internal/tezos/send_transaction.go index f0413b3..9b0b860 100644 --- a/internal/tezos/send_transaction.go +++ b/internal/tezos/send_transaction.go @@ -89,6 +89,7 @@ func (c *tezosConnector) TransactionSend(ctx context.Context, req *ffcapi.Transa }, "", nil } +// nolint:unparam func (c *tezosConnector) signTxRemotely(ctx context.Context, op *codec.Op) error { url := c.signatoryURL + "/keys/" + op.Source.String() requestBody, _ := json.Marshal(hex.EncodeToString(op.WatermarkedBytes()))