Skip to content

Commit

Permalink
ci format check
Browse files Browse the repository at this point in the history
  • Loading branch information
iuwqyir committed Oct 1, 2024
1 parent 23f9e4e commit a3942b0
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 82 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Go Code Format Check

on:
pull_request:
types: [opened, synchronize]

jobs:
format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Run gofmt to check code formatting
run: |
gofmt -l .
continue-on-error: true

- name: Fail if formatting issues found
run: |
FORMATTED=$(gofmt -l .)
if [ -n "$FORMATTED" ]; then
echo "The following files need to be formatted:"
echo "$FORMATTED"
exit 1
fi
12 changes: 6 additions & 6 deletions configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ type LogConfig struct {
}

type PollerConfig struct {
Enabled bool `mapstructure:"enabled"`
Interval int `mapstructure:"interval"`
BlocksPerPoll int `mapstructure:"blocksPerPoll"`
FromBlock int `mapstructure:"fromBlock"`
ForceFromBlock bool `mapstructure:"forceFromBlock"`
UntilBlock int `mapstructure:"untilBlock"`
Enabled bool `mapstructure:"enabled"`
Interval int `mapstructure:"interval"`
BlocksPerPoll int `mapstructure:"blocksPerPoll"`
FromBlock int `mapstructure:"fromBlock"`
ForceFromBlock bool `mapstructure:"forceFromBlock"`
UntilBlock int `mapstructure:"untilBlock"`
}

type CommitterConfig struct {
Expand Down
44 changes: 22 additions & 22 deletions internal/common/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ import (
)

type Block struct {
ChainId *big.Int `json:"chain_id"`
Number *big.Int `json:"number"`
Hash string `json:"hash"`
ParentHash string `json:"parent_hash"`
Timestamp uint64 `json:"timestamp"`
Nonce string `json:"nonce"`
Sha3Uncles string `json:"sha3_uncles"`
MixHash string `json:"mix_hash"`
Miner string `json:"miner"`
StateRoot string `json:"state_root"`
TransactionsRoot string `json:"transactions_root"`
ReceiptsRoot string `json:"receipts_root"`
LogsBloom string `json:"logs_bloom"`
Size uint64 `json:"size"`
ExtraData string `json:"extra_data"`
Difficulty *big.Int `json:"difficulty"`
TotalDifficulty *big.Int `json:"total_difficulty"`
TransactionCount uint64 `json:"transaction_count"`
GasLimit *big.Int `json:"gas_limit"`
GasUsed *big.Int `json:"gas_used"`
WithdrawalsRoot string `json:"withdrawals_root"`
BaseFeePerGas uint64 `json:"base_fee_per_gas"`
ChainId *big.Int `json:"chain_id"`
Number *big.Int `json:"number"`
Hash string `json:"hash"`
ParentHash string `json:"parent_hash"`
Timestamp uint64 `json:"timestamp"`
Nonce string `json:"nonce"`
Sha3Uncles string `json:"sha3_uncles"`
MixHash string `json:"mix_hash"`
Miner string `json:"miner"`
StateRoot string `json:"state_root"`
TransactionsRoot string `json:"transactions_root"`
ReceiptsRoot string `json:"receipts_root"`
LogsBloom string `json:"logs_bloom"`
Size uint64 `json:"size"`
ExtraData string `json:"extra_data"`
Difficulty *big.Int `json:"difficulty"`
TotalDifficulty *big.Int `json:"total_difficulty"`
TransactionCount uint64 `json:"transaction_count"`
GasLimit *big.Int `json:"gas_limit"`
GasUsed *big.Int `json:"gas_used"`
WithdrawalsRoot string `json:"withdrawals_root"`
BaseFeePerGas uint64 `json:"base_fee_per_gas"`
}

type BlockData struct {
Expand Down
20 changes: 10 additions & 10 deletions internal/common/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
)

type Log struct {
ChainId *big.Int `json:"chain_id"`
BlockNumber *big.Int `json:"block_number"`
BlockHash string `json:"block_hash"`
BlockTimestamp uint64 `json:"block_timestamp"`
TransactionHash string `json:"transaction_hash"`
TransactionIndex uint64 `json:"transaction_index"`
LogIndex uint64 `json:"log_index"`
Address string `json:"address"`
Data string `json:"data"`
Topics []string `json:"topics"`
ChainId *big.Int `json:"chain_id"`
BlockNumber *big.Int `json:"block_number"`
BlockHash string `json:"block_hash"`
BlockTimestamp uint64 `json:"block_timestamp"`
TransactionHash string `json:"transaction_hash"`
TransactionIndex uint64 `json:"transaction_index"`
LogIndex uint64 `json:"log_index"`
Address string `json:"address"`
Data string `json:"data"`
Topics []string `json:"topics"`
}
42 changes: 21 additions & 21 deletions internal/common/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ import (
)

type Trace struct {
ChainID *big.Int `json:"chain_id"`
BlockNumber *big.Int `json:"block_number"`
BlockHash string `json:"block_hash"`
BlockTimestamp uint64 `json:"block_timestamp"`
TransactionHash string `json:"transaction_hash"`
TransactionIndex uint64 `json:"transaction_index"`
Subtraces int64 `json:"subtraces"`
TraceAddress []uint64 `json:"trace_address"`
TraceType string `json:"trace_type"`
CallType string `json:"call_type"`
Error string `json:"error"`
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
Gas *big.Int `json:"gas"`
GasUsed *big.Int `json:"gas_used"`
Input string `json:"input"`
Output string `json:"output"`
Value *big.Int `json:"value"`
Author string `json:"author"`
RewardType string `json:"reward_type"`
RefundAddress string `json:"refund_address"`
ChainID *big.Int `json:"chain_id"`
BlockNumber *big.Int `json:"block_number"`
BlockHash string `json:"block_hash"`
BlockTimestamp uint64 `json:"block_timestamp"`
TransactionHash string `json:"transaction_hash"`
TransactionIndex uint64 `json:"transaction_index"`
Subtraces int64 `json:"subtraces"`
TraceAddress []uint64 `json:"trace_address"`
TraceType string `json:"trace_type"`
CallType string `json:"call_type"`
Error string `json:"error"`
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
Gas *big.Int `json:"gas"`
GasUsed *big.Int `json:"gas_used"`
Input string `json:"input"`
Output string `json:"output"`
Value *big.Int `json:"value"`
Author string `json:"author"`
RewardType string `json:"reward_type"`
RefundAddress string `json:"refund_address"`
}
40 changes: 20 additions & 20 deletions internal/common/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ import (
)

type Transaction struct {
ChainId *big.Int `json:"chain_id"`
Hash string `json:"hash"`
Nonce uint64 `json:"nonce"`
BlockHash string `json:"block_hash"`
BlockNumber *big.Int `json:"block_number"`
BlockTimestamp uint64 `json:"block_timestamp"`
TransactionIndex uint64 `json:"transaction_index"`
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
Value *big.Int `json:"value"`
Gas uint64 `json:"gas"`
GasPrice *big.Int `json:"gas_price"`
Data string `json:"data"`
MaxFeePerGas *big.Int `json:"max_fee_per_gas"`
MaxPriorityFeePerGas *big.Int `json:"max_priority_fee_per_gas"`
TransactionType uint8 `json:"transaction_type"`
R *big.Int `json:"r"`
S *big.Int `json:"s"`
V *big.Int `json:"v"`
AccessListJson string `json:"access_list_json"`
ChainId *big.Int `json:"chain_id"`
Hash string `json:"hash"`
Nonce uint64 `json:"nonce"`
BlockHash string `json:"block_hash"`
BlockNumber *big.Int `json:"block_number"`
BlockTimestamp uint64 `json:"block_timestamp"`
TransactionIndex uint64 `json:"transaction_index"`
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
Value *big.Int `json:"value"`
Gas uint64 `json:"gas"`
GasPrice *big.Int `json:"gas_price"`
Data string `json:"data"`
MaxFeePerGas *big.Int `json:"max_fee_per_gas"`
MaxPriorityFeePerGas *big.Int `json:"max_priority_fee_per_gas"`
TransactionType uint8 `json:"transaction_type"`
R *big.Int `json:"r"`
S *big.Int `json:"s"`
V *big.Int `json:"v"`
AccessListJson string `json:"access_list_json"`
}
2 changes: 1 addition & 1 deletion internal/handlers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ func Handler(r *chi.Mux) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("ok"))
})
}
}
2 changes: 1 addition & 1 deletion internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ var (
Name: "failure_recoverer_first_block_in_batch",
Help: "The first block number in the failure recoverer batch",
})
)
)
2 changes: 1 addition & 1 deletion internal/middleware/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ func Authorization(next http.Handler) http.Handler {

func validateCredentials(username, password string) bool {
return username == "admin" && password == "admin"
}
}

0 comments on commit a3942b0

Please sign in to comment.