Skip to content

Commit

Permalink
feat:optimize ToQNGTx
Browse files Browse the repository at this point in the history
  • Loading branch information
lochjin committed Dec 19, 2024
1 parent 09ae62d commit be7c0cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions meerevm/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"math/big"
"strconv"
"strings"
"time"
)

func ReverseBytes(bs *[]byte) *[]byte {
Expand Down Expand Up @@ -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())
Expand All @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions meerevm/meer/meerpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit be7c0cf

Please sign in to comment.