@@ -20,14 +20,22 @@ import (
2020 "github.com/vechain/thor/v2/tx"
2121)
2222
23+ type txSource string
24+
25+ const (
26+ txSourceLocal txSource = "local"
27+ txSourceRemote txSource = "remote"
28+ txSourceFill txSource = "fill"
29+ )
30+
2331type TxObject struct {
2432 * tx.Transaction
2533 resolved * runtime.ResolvedTransaction
2634
27- timeAdded int64
28- localSubmitted bool // tx is submitted locally on this node, or synced remotely from p2p .
29- payer * thor.Address // payer of the tx, either origin, delegator, or on-chain delegation payer
30- cost * big.Int // total tx cost the payer needs to pay before execution(gas price * gas)
35+ timeAdded int64
36+ source txSource // where the tx came from: local, remote or fill .
37+ payer * thor.Address // payer of the tx, either origin, delegator, or on-chain delegation payer
38+ cost * big.Int // total tx cost the payer needs to pay before execution(gas price * gas)
3139
3240 // basic unit of tip price for the validator, before GALACTICA it's the overallGasPrice(provedWork included) and validator
3341 // gets <reward-ratio>% of the tip, after GALACTICA it's the effective priority fee per gas and validator gets 100% of the tip
@@ -37,19 +45,31 @@ type TxObject struct {
3745}
3846
3947func ResolveTx (tx * tx.Transaction , localSubmitted bool ) (* TxObject , error ) {
48+ source := txSourceRemote
49+ if localSubmitted {
50+ source = txSourceLocal
51+ }
52+ return resolveTxWithSource (tx , source )
53+ }
54+
55+ func resolveTxWithSource (tx * tx.Transaction , source txSource ) (* TxObject , error ) {
4056 resolved , err := runtime .ResolveTransaction (tx )
4157 if err != nil {
4258 return nil , err
4359 }
4460
4561 return & TxObject {
46- Transaction : tx ,
47- resolved : resolved ,
48- timeAdded : time .Now ().UnixNano (),
49- localSubmitted : localSubmitted ,
62+ Transaction : tx ,
63+ resolved : resolved ,
64+ timeAdded : time .Now ().UnixNano (),
65+ source : source ,
5066 }, nil
5167}
5268
69+ func (o * TxObject ) localSubmitted () bool {
70+ return o .source == txSourceLocal
71+ }
72+
5373func (o * TxObject ) Origin () thor.Address {
5474 return o .resolved .Origin
5575}
0 commit comments