Skip to content

Commit 1f2e0e3

Browse files
author
Jason
committed
细节完善
1 parent 22b99e0 commit 1f2e0e3

6 files changed

Lines changed: 22 additions & 18 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o scan main.go
3535
```
3636

3737
## 使用步骤
38-
1. 导入数据库,我用的`mariadb v10.7.3`
39-
* 若扫描链交易记录,则导入`sql`目录中的`app_transaction.sql`到mysql数据库,
40-
* 若使用zkf的统计和扫描,则导入`sql`目录中的`zkf.sql`到mysql数据库,
38+
1. 手动导入数据库,我用的`mariadb v10.7.3`
39+
* 若扫描链交易记录,则导入`sql`目录中的`tx-scan.sql`到mysql数据库,
40+
* 若使用zkf的统计和扫描,则导入`sql`目录中的`tx-zkf.sql`到mysql数据库,
4141
2. 执行上一步骤编译好的程序或者从此处下载最新已编译好的版本[evm-scan-release](https://github.com/bitxx/evm-scan/releases)(说明:配置文件中已经对各个配置做了详细描述):
4242
```shell
4343
# 根据配置文件描述,完成参数配置

app/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ func (a *App) ScanTransactionsByNumber(blockNumStart, blockNumEnd uint64) {
115115
GasUsed: tx.GasUsed,
116116
TransactionIndex: tx.TransactionIndex,
117117
ReceiptStatus: tx.ReceiptStatus,
118+
Nonce: tx.Nonce,
118119
Type: tx.Type,
119120
Value: tx.Value,
120-
Protected: protected,
121-
CreatedAt: &createTime,
121+
122+
Protected: protected,
123+
CreatedAt: &createTime,
122124
}
123125
ts = append(ts, t)
124126
}

app/zkf/model/zkf.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const (
1313

1414
type ZkfStatGas struct {
1515
Id uint64 `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"`
16-
BlockStart uint64 `json:"blockStart" gorm:"column:block_start;type:int(11);comment:块开始高度"`
17-
BlockEnd uint64 `json:"blockEnd" gorm:"column:block_end;type:int(11);comment:块截止高度"`
16+
BlockStart uint64 `json:"blockStart" gorm:"column:block_start;type:bigint(20);comment:块开始高度"`
17+
BlockEnd uint64 `json:"blockEnd" gorm:"column:block_end;type:bigint(20);comment:块截止高度"`
1818
DateStart *time.Time `json:"dateStart" gorm:"column:date_start;type:datetime;comment:开始时间"`
1919
DateEnd *time.Time `json:"dateEnd" gorm:"column:date_end;type:datetime;comment:截止时间"`
2020
TotalTxCount int64 `json:"totalTxCount" gorm:"column:total_tx_count;type:int(11);comment:交易总笔数"`

model/transaction.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import (
77

88
type Transaction struct {
99
Id uint64 `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"`
10-
BlockNumber uint64 `json:"blockNumber" gorm:"column:block_number;type:int(11);comment:块高度"`
10+
BlockNumber uint64 `json:"blockNumber" gorm:"column:block_number;type:bigint(20);comment:块高度"`
1111
Hash string `json:"hash" gorm:"column:hash;type:varchar(200);comment:hash"`
1212
From string `json:"from" gorm:"column:from;type:varchar(80);comment:from"`
1313
To string `json:"to" gorm:"column:to;type:varchar(80);comment:to"`
1414
EffectiveGasPrice decimal.Decimal `json:"effectiveGasPrice" gorm:"column:effective_gas_price;type:decimal(30,0);comment:gas单价格"`
15-
GasUsed uint64 `json:"gasUsed" gorm:"column:gas_used;type:int(11);comment:gas used"`
15+
GasUsed uint64 `json:"gasUsed" gorm:"column:gas_used;type:bigint(20);comment:gas used"`
1616
TransactionIndex uint `json:"transactionIndex" gorm:"column:transaction_index;type:int(11);comment:交易索引"`
17-
ReceiptStatus uint64 `json:"receiptStatus" gorm:"column:receipt_status;type:int(11);comment:交易回执状态"`
17+
ReceiptStatus uint64 `json:"receiptStatus" gorm:"column:receipt_status;type:bigint(20);comment:交易回执状态"`
18+
Nonce uint64 `json:"nonce" gorm:"column:nonce;type:bigint(20);comment:nonce"`
1819
Type string `json:"type" gorm:"column:type;type:char(1);comment:账变类型"`
1920
Value decimal.Decimal `json:"value" gorm:"column:value;type:decimal(30,0);comment:账变数量"`
2021
Protected string `json:"protected" gorm:"column:protected;type:char(1);comment:是否保护(1-是 2-否)"`
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
44
Source Server : my-server
55
Source Server Type : MySQL
6-
Source Server Version : 100703 (10.7.3-MariaDB-log)
6+
Source Server Version : 100703
77
Source Host : 127.0.0.1:3306
88
Source Schema : evm-scan
99
1010
Target Server Type : MySQL
11-
Target Server Version : 100703 (10.7.3-MariaDB-log)
11+
Target Server Version : 100703
1212
File Encoding : 65001
1313
14-
Date: 27/02/2024 22:14:12
14+
Date: 28/02/2024 09:33:22
1515
*/
1616

1717
SET NAMES utf8mb4;
@@ -32,6 +32,7 @@ CREATE TABLE `app_transaction` (
3232
`type` char(1) DEFAULT '0' COMMENT '交易类型',
3333
`effective_gas_price` decimal(30,0) DEFAULT 0 COMMENT 'gas price',
3434
`gas_used` bigint(20) DEFAULT 0 COMMENT 'gas使用',
35+
`nonce` bigint(20) DEFAULT 0 COMMENT 'nonce',
3536
`transaction_index` int(11) DEFAULT 0 COMMENT '交易索引',
3637
`receipt_status` int(11) DEFAULT 0 COMMENT '回执状态',
3738
`created_at` datetime DEFAULT current_timestamp() COMMENT '创建时间',

sql/zkf.sql renamed to sql/zkf-scan.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
44
Source Server : my-server
55
Source Server Type : MySQL
6-
Source Server Version : 100703 (10.7.3-MariaDB-log)
6+
Source Server Version : 100703
77
Source Host : 127.0.0.1:3306
88
Source Schema : evm-scan
99
1010
Target Server Type : MySQL
11-
Target Server Version : 100703 (10.7.3-MariaDB-log)
11+
Target Server Version : 100703
1212
File Encoding : 65001
1313
14-
Date: 27/02/2024 22:38:30
14+
Date: 28/02/2024 09:30:30
1515
*/
1616

1717
SET NAMES utf8mb4;
@@ -34,7 +34,7 @@ CREATE TABLE `app_zkf_stat_daily_gas` (
3434
`updated_at` datetime DEFAULT current_timestamp() COMMENT '更新时间',
3535
`created_at` datetime DEFAULT current_timestamp() COMMENT '创建时间',
3636
PRIMARY KEY (`id`) USING BTREE
37-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='zkf统计每周Gas';
37+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='zkf统计每日Gas';
3838

3939
-- ----------------------------
4040
-- Table structure for app_zkf_stat_hours_gas
@@ -53,7 +53,7 @@ CREATE TABLE `app_zkf_stat_hours_gas` (
5353
`updated_at` datetime DEFAULT current_timestamp() COMMENT '更新时间',
5454
`created_at` datetime DEFAULT current_timestamp() COMMENT '创建时间',
5555
PRIMARY KEY (`id`) USING BTREE
56-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='zkf统计每周Gas';
56+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='zkf统计每小时Gas';
5757

5858
-- ----------------------------
5959
-- Table structure for app_zkf_stat_weekly_gas

0 commit comments

Comments
 (0)