github.com/ImPedro29/bor@v0.2.7/consensus/bor/clerk.go (about)

     1  package bor
     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 representatin of span
    27  func (e *EventRecordWithTime) String() string {
    28  	return fmt.Sprintf(
    29  		"id %v, contract %v, data: %v, txHash: %v, logIndex: %v, chainId: %v, time %s",
    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  	)
    38  }
    39  
    40  func (e *EventRecordWithTime) BuildEventRecord() *EventRecord {
    41  	return &EventRecord{
    42  		ID:       e.ID,
    43  		Contract: e.Contract,
    44  		Data:     e.Data,
    45  		TxHash:   e.TxHash,
    46  		LogIndex: e.LogIndex,
    47  		ChainID:  e.ChainID,
    48  	}
    49  }