github.com/palisadeinc/bor@v0.0.0-20230615125219-ab7196213d15/consensus/bor/clerk/clerk.go (about) 1 package clerk 2 3 import ( 4 "fmt" 5 "time" 6 7 "github.com/ethereum/go-ethereum/common" 8 "github.com/ethereum/go-ethereum/common/hexutil" 9 ) 10 11 // EventRecord represents state record 12 type EventRecord struct { 13 ID uint64 `json:"id" yaml:"id"` 14 Contract common.Address `json:"contract" yaml:"contract"` 15 Data hexutil.Bytes `json:"data" yaml:"data"` 16 TxHash common.Hash `json:"tx_hash" yaml:"tx_hash"` 17 LogIndex uint64 `json:"log_index" yaml:"log_index"` 18 ChainID string `json:"bor_chain_id" yaml:"bor_chain_id"` 19 } 20 21 type EventRecordWithTime struct { 22 EventRecord 23 Time time.Time `json:"record_time" yaml:"record_time"` 24 } 25 26 // String returns the string representation of EventRecord 27 func (e *EventRecordWithTime) String(gasUsed uint64) string { 28 return fmt.Sprintf( 29 "id %v, contract %v, data: %v, txHash: %v, logIndex: %v, chainId: %v, time %s, gasUsed %d", 30 e.ID, 31 e.Contract.String(), 32 e.Data.String(), 33 e.TxHash.Hex(), 34 e.LogIndex, 35 e.ChainID, 36 e.Time.Format(time.RFC3339), 37 gasUsed, 38 ) 39 } 40 41 func (e *EventRecordWithTime) BuildEventRecord() *EventRecord { 42 return &EventRecord{ 43 ID: e.ID, 44 Contract: e.Contract, 45 Data: e.Data, 46 TxHash: e.TxHash, 47 LogIndex: e.LogIndex, 48 ChainID: e.ChainID, 49 } 50 }