Skip to content

Commit

Permalink
xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
ntminh committed Dec 24, 2021
1 parent dddf73a commit 84207d2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func NewTx(inner TxData) *Transaction {
return tx
}

func NewTxWithTime(inner TxData, inputTime time.Time) *Transaction {
tx := new(Transaction)
tx.setDecodedWithTime(inner.copy(), 0, inputTime)
return tx
}

// TxData is the underlying data of a transaction.
//
// This is implemented by DynamicFeeTx, LegacyTx and AccessListTx.
Expand Down Expand Up @@ -200,6 +206,14 @@ func (tx *Transaction) setDecoded(inner TxData, size int) {
}
}

func (tx *Transaction) setDecodedWithTime(inner TxData, size int, inputTime time.Time) {
tx.inner = inner
tx.time = inputTime
if size > 0 {
tx.size.Store(common.StorageSize(size))
}
}

func sanityCheckSignature(v *big.Int, r *big.Int, s *big.Int, maybeProtected bool) error {
if isProtectedV(v) && !maybeProtected {
return ErrUnexpectedProtection
Expand Down Expand Up @@ -245,6 +259,10 @@ func (tx *Transaction) Protected() bool {
}
}

func (tx *Transaction) Time() time.Time {
return tx.time
}

// Type returns the transaction type.
func (tx *Transaction) Type() uint8 {
return tx.inner.txType()
Expand Down

0 comments on commit 84207d2

Please sign in to comment.