Adding individual gasUsed

This commit is contained in:
Shivam Sharma 2022-05-20 15:57:08 +05:30
parent b88353c27d
commit 20d99d94df
2 changed files with 6 additions and 4 deletions

View file

@ -23,10 +23,10 @@ type EventRecordWithTime struct {
Time time.Time `json:"record_time" yaml:"record_time"`
}
// String returns the string representatin of span
func (e *EventRecordWithTime) String() string {
// String returns the string representation of EventRecord
func (e *EventRecordWithTime) String(gasUsed uint64) string {
return fmt.Sprintf(
"id %v, contract %v, data: %v, txHash: %v, logIndex: %v, chainId: %v, time %s",
"id %v, contract %v, data: %v, txHash: %v, logIndex: %v, chainId: %v, time %s, gasUsed %d",
e.ID,
e.Contract.String(),
e.Data.String(),
@ -34,6 +34,7 @@ func (e *EventRecordWithTime) String() string {
e.LogIndex,
e.ChainID,
e.Time.Format(time.RFC3339),
gasUsed,
)
}

View file

@ -66,9 +66,10 @@ func (gc *GenesisContractsClient) CommitState(
log.Error("Unable to pack tx for commitState", "error", err)
return 0, err
}
log.Info("→ committing new state", "eventRecord", event.String())
msg := getSystemMessage(common.HexToAddress(gc.StateReceiverContract), data)
gasUsed, err := applyMessage(msg, state, header, gc.chainConfig, chCtx)
// Logging event log with time and individual gasUsed
log.Info("→ committing new state", "eventRecord", event.String(gasUsed))
if err != nil {
return 0, err
}