From be7c0cfd37cbfc6a6f8fa043b30e4af56291008e Mon Sep 17 00:00:00 2001 From: Jin Date: Thu, 19 Dec 2024 09:27:40 +0800 Subject: [PATCH] feat:optimize ToQNGTx --- meerevm/common/utils.go | 8 ++------ meerevm/meer/meerpool.go | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/meerevm/common/utils.go b/meerevm/common/utils.go index 71fe8cdc..02485188 100644 --- a/meerevm/common/utils.go +++ b/meerevm/common/utils.go @@ -24,7 +24,6 @@ import ( "math/big" "strconv" "strings" - "time" ) func ReverseBytes(bs *[]byte) *[]byte { @@ -84,7 +83,7 @@ func FromEVMHash(h common.Hash) *hash.Hash { return th } -func ToQNGTx(tx *types.Transaction, timestamp int64, newEncoding bool) *qtypes.Tx { +func ToQNGTx(tx *types.Transaction, newEncoding bool) *qtypes.Tx { txmb, err := tx.MarshalBinary() if err != nil { log.Error(err.Error()) @@ -101,10 +100,7 @@ func ToQNGTx(tx *types.Transaction, timestamp int64, newEncoding bool) *qtypes.T qtxh := hash.MustBytesToHash(qtxhb) mtx := qtypes.NewTransaction() - - if timestamp > 0 { - mtx.Timestamp = time.Unix(timestamp, 0) - } + mtx.Timestamp = tx.Time() mtx.AddTxIn(&qtypes.TxInput{ PreviousOut: *qtypes.NewOutPoint(&qtxh, qtypes.SupperPrevOutIndex), diff --git a/meerevm/meer/meerpool.go b/meerevm/meer/meerpool.go index 9d731a77..608b6820 100644 --- a/meerevm/meer/meerpool.go +++ b/meerevm/meer/meerpool.go @@ -167,7 +167,7 @@ func (m *MeerPool) prepareMeerChangeTxs(txs []*types.Transaction) bool { } all++ if meerchange.IsMeerChangeTx(tx) { - vmtx, err := meer.NewVMTx(qcommon.ToQNGTx(tx, 0, true).Tx, nil) + vmtx, err := meer.NewVMTx(qcommon.ToQNGTx(tx, true).Tx, nil) if err != nil { log.Error(err.Error()) m.ethTxPool.RemoveTx(tx.Hash(), true) @@ -244,7 +244,7 @@ func (m *MeerPool) updateTemplate(force bool) error { txsNum := len(block.Transactions()) if txsNum > 0 { for _, tx := range block.Transactions() { - mtx := qcommon.ToQNGTx(tx, 0, true) + mtx := qcommon.ToQNGTx(tx, true) stx := &snapshotTx{tx: mtx, eHash: tx.Hash()} m.snapshotQTxsM[mtx.Hash().String()] = stx m.snapshotTxsM[tx.Hash().String()] = stx