From 1aa2973f662e472af88c0e4893aaec3c63d53aae Mon Sep 17 00:00:00 2001 From: brad Date: Mon, 26 Feb 2024 16:31:37 +0800 Subject: [PATCH 1/2] fix bug --- client/evm/client.go | 5 ++--- explorer/indexer.go | 5 ++--- model/transaction.go | 34 ++++++++++++++++++---------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/client/evm/client.go b/client/evm/client.go index fb4a0c1..553d333 100644 --- a/client/evm/client.go +++ b/client/evm/client.go @@ -24,7 +24,6 @@ package evm import ( "context" - "encoding/json" "errors" "fmt" "github.com/ethereum/go-ethereum" @@ -89,8 +88,8 @@ func (ec *RawClient) CallContext(ctx context.Context, result interface{}, method if result == nil { return rpc.ErrNoResult } - d, _ := json.Marshal(result) - xylog.Logger.Debugf("CallContext result=%v", string(d)) + //d, _ := json.Marshal(result) + //xylog.Logger.Debugf("CallContext result=%v", string(d)) return nil } diff --git a/explorer/indexer.go b/explorer/indexer.go index 59026cc..5776e8e 100644 --- a/explorer/indexer.go +++ b/explorer/indexer.go @@ -23,7 +23,6 @@ package explorer import ( - "encoding/json" "errors" "fmt" "github.com/alitto/pond" @@ -160,8 +159,8 @@ func (e *Explorer) handleTxs(block *xycommon.RpcBlock, txs []*xycommon.RpcTransa xylog.Logger.Infof("handle txs, parse & async sink cost[%v], txs[%d]", time.Since(startTs), len(txs)) }() - b, _ := json.Marshal(block) - xylog.Logger.Debugf("handleTxs rpc block =%v", string(b)) + //b, _ := json.Marshal(block) + //xylog.Logger.Debugf("handleTxs rpc block =%v", string(b)) blockTxResults := make([]*devents.DBModelEvent, 0, len(txs)) for _, tx := range txs { diff --git a/model/transaction.go b/model/transaction.go index b1a9a0a..10b8433 100644 --- a/model/transaction.go +++ b/model/transaction.go @@ -105,22 +105,24 @@ func (BalanceTxn) TableName() string { } type Transaction struct { - ID uint64 `gorm:"primaryKey" json:"id"` - ChainId int64 `json:"chain_id" gorm:"-:all"` - Protocol string `json:"protocol" gorm:"column:protocol"` // protocol name - Chain string `json:"chain" gorm:"column:chain"` // chain name - BlockHeight uint64 `json:"block_height" gorm:"column:block_height"` // block height - PositionInBlock uint64 `json:"position_in_block" gorm:"column:position_in_block"` // Position in Block - BlockTime time.Time `json:"block_time" gorm:"column:block_time"` // block time - TxHash []byte `json:"tx_hash" gorm:"column:tx_hash"` // tx hash - From string `json:"from" gorm:"column:from"` // from address - To string `json:"to" gorm:"column:to"` // to address - Op string `json:"op" gorm:"column:op"` // op code - Gas int64 `json:"gas" gorm:"column:gas"` // gas - GasPrice int64 `json:"gas_price" gorm:"column:gas_price"` // gas price - Status int8 `json:"status" gorm:"column:status"` // tx status - CreatedAt time.Time `json:"created_at" gorm:"column:created_at"` - UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"` + ID uint64 `gorm:"primaryKey" json:"id"` + ChainId int64 `json:"chain_id" gorm:"-:all"` + Protocol string `json:"protocol" gorm:"column:protocol"` // protocol name + Chain string `json:"chain" gorm:"column:chain"` // chain name + BlockHeight uint64 `json:"block_height" gorm:"column:block_height"` // block height + PositionInBlock uint64 `json:"position_in_block" gorm:"column:position_in_block"` // Position in Block + BlockTime time.Time `json:"block_time" gorm:"column:block_time"` // block time + TxHash []byte `json:"tx_hash" gorm:"column:tx_hash"` // tx hash + From string `json:"from" gorm:"column:from"` // from address + To string `json:"to" gorm:"column:to"` // to address + Op string `json:"op" gorm:"column:op"` // op code + Tick string `json:"tick" gorm:"column:tick"` // inscription code + Amount decimal.Decimal `json:"amt" gorm:"column:amt;type:decimal(38,18)"` // balance + Gas int64 `json:"gas" gorm:"column:gas"` // gas + GasPrice int64 `json:"gas_price" gorm:"column:gas_price"` // gas price + Status int8 `json:"status" gorm:"column:status"` // tx status + CreatedAt time.Time `json:"created_at" gorm:"column:created_at"` + UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"` } func (Transaction) TableName() string { From 4bcf49b4641d95488bab9a49dbea72b1a4a1da9a Mon Sep 17 00:00:00 2001 From: brad Date: Mon, 26 Feb 2024 16:33:59 +0800 Subject: [PATCH 2/2] add log --- client/evm/client.go | 5 +++-- explorer/indexer.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/evm/client.go b/client/evm/client.go index 553d333..fb4a0c1 100644 --- a/client/evm/client.go +++ b/client/evm/client.go @@ -24,6 +24,7 @@ package evm import ( "context" + "encoding/json" "errors" "fmt" "github.com/ethereum/go-ethereum" @@ -88,8 +89,8 @@ func (ec *RawClient) CallContext(ctx context.Context, result interface{}, method if result == nil { return rpc.ErrNoResult } - //d, _ := json.Marshal(result) - //xylog.Logger.Debugf("CallContext result=%v", string(d)) + d, _ := json.Marshal(result) + xylog.Logger.Debugf("CallContext result=%v", string(d)) return nil } diff --git a/explorer/indexer.go b/explorer/indexer.go index 5776e8e..59026cc 100644 --- a/explorer/indexer.go +++ b/explorer/indexer.go @@ -23,6 +23,7 @@ package explorer import ( + "encoding/json" "errors" "fmt" "github.com/alitto/pond" @@ -159,8 +160,8 @@ func (e *Explorer) handleTxs(block *xycommon.RpcBlock, txs []*xycommon.RpcTransa xylog.Logger.Infof("handle txs, parse & async sink cost[%v], txs[%d]", time.Since(startTs), len(txs)) }() - //b, _ := json.Marshal(block) - //xylog.Logger.Debugf("handleTxs rpc block =%v", string(b)) + b, _ := json.Marshal(block) + xylog.Logger.Debugf("handleTxs rpc block =%v", string(b)) blockTxResults := make([]*devents.DBModelEvent, 0, len(txs)) for _, tx := range txs {