Skip to content

Commit 4178d4c

Browse files
committed
linter fixes
1 parent cc8c764 commit 4178d4c

File tree

5 files changed

+15
-90
lines changed

5 files changed

+15
-90
lines changed

pkg/solana/logpoller/models.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ type Filter struct {
2121

2222
type Log struct {
2323
ID int64
24-
FilterId int64
25-
ChainId string
24+
FilterID int64
25+
ChainID string
2626
LogIndex int64
2727
BlockHash Hash
2828
BlockNumber int64

pkg/solana/logpoller/orm.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ func (o *DSORM) insertLogsWithinTx(ctx context.Context, logs []Log, tx sqlutil.D
119119

120120
func (o *DSORM) validateLogs(logs []Log) error {
121121
for _, log := range logs {
122-
if o.chainID != log.ChainId {
123-
return fmt.Errorf("invalid chainID in log got %v want %v", log.ChainId, o.chainID)
122+
if o.chainID != log.ChainID {
123+
return fmt.Errorf("invalid chainID in log got %v want %v", log.ChainID, o.chainID)
124124
}
125125
}
126126
return nil

pkg/solana/logpoller/orm_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ func TestLogPollerLogs(t *testing.T) {
137137
signature, err := privateKey.Sign(data)
138138
require.NoError(t, err)
139139
log := Log{
140-
FilterId: filterID,
141-
ChainId: chainID,
140+
FilterID: filterID,
141+
ChainID: chainID,
142142
LogIndex: 1,
143143
BlockHash: Hash(pubKey),
144144
BlockNumber: 10,

pkg/solana/logpoller/query.go

+7-81
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import (
55
"fmt"
66
"strings"
77
"time"
8-
9-
"github.com/gagliardetto/solana-go"
10-
"github.com/lib/pq"
118
)
129

1310
// queryArgs is a helper for building the arguments to a postgres query created by DSORM
@@ -18,10 +15,10 @@ type queryArgs struct {
1815
err []error
1916
}
2017

21-
func newQueryArgs(chainId string) *queryArgs {
18+
func newQueryArgs(chainID string) *queryArgs {
2219
return &queryArgs{
2320
args: map[string]any{
24-
"chain_id": chainId,
21+
"chain_id": chainID,
2522
},
2623
idxLookup: make(map[string]uint8),
2724
err: []error{},
@@ -34,18 +31,12 @@ func (q *queryArgs) withField(fieldName string, value any) *queryArgs {
3431
return args
3532
}
3633

37-
func (q *queryArgs) withIndexedField(fieldName string, value any) string {
38-
field, _ := q.withIndexableField(fieldName, value, true)
39-
40-
return field
41-
}
42-
4334
func (q *queryArgs) withIndexableField(fieldName string, value any, addIndex bool) (string, *queryArgs) {
4435
if addIndex {
4536
idx := q.nextIdx(fieldName)
4637
idxName := fmt.Sprintf("%s_%d", fieldName, idx)
4738

48-
q.idxLookup[fieldName] = uint8(idx)
39+
q.idxLookup[fieldName] = idx
4940
fieldName = idxName
5041
}
5142

@@ -54,13 +45,13 @@ func (q *queryArgs) withIndexableField(fieldName string, value any, addIndex boo
5445
return fieldName, q
5546
}
5647

57-
func (q *queryArgs) nextIdx(baseFieldName string) int {
48+
func (q *queryArgs) nextIdx(baseFieldName string) uint8 {
5849
idx, ok := q.idxLookup[baseFieldName]
5950
if !ok {
6051
return 0
6152
}
6253

63-
return int(idx) + 1
54+
return idx + 1
6455
}
6556

6657
// withName sets the Name field in queryArgs.
@@ -108,73 +99,8 @@ func (q *queryArgs) withMaxLogsKept(maxLogsKept int64) *queryArgs {
10899
return q.withField("max_logs_kept", maxLogsKept)
109100
}
110101

111-
// withID sets the ID field in Log.
112-
func (q *queryArgs) withID(id int64) *queryArgs {
113-
return q.withField("id", id)
114-
}
115-
116-
// withFilterId sets the FilterId field in Log.
117-
func (q *queryArgs) withFilterId(filterId int64) *queryArgs {
118-
return q.withField("filter_id", filterId)
119-
}
120-
121-
// withChainId sets the ChainId field in Log.
122-
func (q *queryArgs) withChainId(chainId string) *queryArgs {
123-
return q.withField("chain_id", chainId)
124-
}
125-
126-
// withLogIndex sets the LogIndex field in Log.
127-
func (q *queryArgs) withLogIndex(logIndex int64) *queryArgs {
128-
return q.withField("log_index", logIndex)
129-
}
130-
131-
// withBlockHash sets the BlockHash field in Log.
132-
func (q *queryArgs) withBlockHash(blockHash solana.Hash) *queryArgs {
133-
return q.withField("block_hash", blockHash)
134-
}
135-
136-
// withBlockNumber sets the BlockNumber field in Log.
137-
func (q *queryArgs) withBlockNumber(blockNumber int64) *queryArgs {
138-
return q.withField("block_number", blockNumber)
139-
}
140-
141-
// withBlockTimestamp sets the BlockTimestamp field in Log.
142-
func (q *queryArgs) withBlockTimestamp(blockTimestamp time.Time) *queryArgs {
143-
return q.withField("block_timestamp", blockTimestamp)
144-
}
145-
146-
// withSubkeyValues sets the SubkeyValues field in Log.
147-
func (q *queryArgs) withSubkeyValues(subkeyValues pq.ByteaArray) *queryArgs {
148-
return q.withField("subkey_values", subkeyValues)
149-
}
150-
151-
// withTxHash sets the TxHash field in Log.
152-
func (q *queryArgs) withTxHash(txHash solana.Signature) *queryArgs {
153-
return q.withField("tx_hash", txHash)
154-
}
155-
156-
// withData sets the Data field in Log.
157-
func (q *queryArgs) withData(data []byte) *queryArgs {
158-
return q.withField("data", data)
159-
}
160-
161-
// withCreatedAt sets the CreatedAt field in Log.
162-
func (q *queryArgs) withCreatedAt(createdAt time.Time) *queryArgs {
163-
return q.withField("created_at", createdAt)
164-
}
165-
166-
// withExpiresAt sets the ExpiresAt field in Log.
167-
func (q *queryArgs) withExpiresAt(expiresAt *time.Time) *queryArgs {
168-
return q.withField("expires_at", expiresAt)
169-
}
170-
171-
// withSequenceNum sets the SequenceNum field in Log.
172-
func (q *queryArgs) withSequenceNum(sequenceNum int64) *queryArgs {
173-
return q.withField("sequence_num", sequenceNum)
174-
}
175-
176-
func newQueryArgsForEvent(chainId string, address PublicKey, eventSig []byte) *queryArgs {
177-
return newQueryArgs(chainId).
102+
func newQueryArgsForEvent(chainID string, address PublicKey, eventSig []byte) *queryArgs {
103+
return newQueryArgs(chainID).
178104
withAddress(address).
179105
withEventSig(eventSig)
180106
}

pkg/solana/logpoller/types.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func scanFixedLengthArray(name string, maxLength int, src interface{}, dest []by
7070

7171
type SubkeyPaths [][]string
7272

73-
func (k SubkeyPaths) Value() (driver.Value, error) {
74-
return json.Marshal([][]string(k))
73+
func (p SubkeyPaths) Value() (driver.Value, error) {
74+
return json.Marshal([][]string(p))
7575
}
7676

7777
func (p *SubkeyPaths) Scan(src interface{}) error {
@@ -95,5 +95,4 @@ func (p *SubkeyPaths) Scan(src interface{}) error {
9595
}
9696

9797
return nil
98-
9998
}

0 commit comments

Comments
 (0)