core/txpool rename tracker -> locals, re-add locals-gauge
This commit is contained in:
parent
8639d5c044
commit
3c33b7b179
|
@ -14,7 +14,7 @@
|
|||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package tracker
|
||||
package locals
|
||||
|
||||
import (
|
||||
"errors"
|
|
@ -14,8 +14,8 @@
|
|||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Package legacypool implements the normal EVM execution transaction pool.
|
||||
package tracker
|
||||
// Package locals implements tracking for "local" transactions
|
||||
package locals
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
@ -26,11 +26,15 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
var recheckInterval = time.Minute
|
||||
var (
|
||||
recheckInterval = time.Minute
|
||||
localGauge = metrics.GetOrRegisterGauge("txpool/local", nil)
|
||||
)
|
||||
|
||||
// TxTracker is a struct used to track priority transactions; it will check from
|
||||
// time to time if the main pool has forgotten about any of the transaction
|
||||
|
@ -88,11 +92,11 @@ func (tracker *TxTracker) TrackAll(txs []*types.Transaction) {
|
|||
if _, ok := tracker.all[tx.Hash()]; ok {
|
||||
continue
|
||||
}
|
||||
tracker.all[tx.Hash()] = tx
|
||||
addr, err := types.Sender(tracker.signer, tx)
|
||||
if err != nil { // Ignore this tx
|
||||
continue
|
||||
}
|
||||
tracker.all[tx.Hash()] = tx
|
||||
if tracker.byAddr[addr] == nil {
|
||||
tracker.byAddr[addr] = legacypool.NewSortedMap()
|
||||
}
|
||||
|
@ -101,6 +105,7 @@ func (tracker *TxTracker) TrackAll(txs []*types.Transaction) {
|
|||
_ = tracker.journal.insert(tx)
|
||||
}
|
||||
}
|
||||
localGauge.Update(int64(len(tracker.all)))
|
||||
}
|
||||
|
||||
// recheck checks and returns any transactions that needs to be resubmitted.
|
||||
|
@ -142,6 +147,7 @@ func (tracker *TxTracker) recheck(journalCheck bool) (resubmits []*types.Transac
|
|||
})
|
||||
}
|
||||
}
|
||||
localGauge.Update(int64(len(tracker.all)))
|
||||
log.Debug("Tx tracker status", "need-resubmit", len(resubmits), "stale", numStales, "ok", numOk)
|
||||
return resubmits, rejournal
|
||||
}
|
|
@ -36,7 +36,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/txpool/blobpool"
|
||||
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
|
||||
"github.com/ethereum/go-ethereum/core/txpool/tracker"
|
||||
"github.com/ethereum/go-ethereum/core/txpool/locals"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
|
@ -71,7 +71,7 @@ type Ethereum struct {
|
|||
// core protocol objects
|
||||
config *ethconfig.Config
|
||||
txPool *txpool.TxPool
|
||||
localTxTracker *tracker.TxTracker
|
||||
localTxTracker *locals.TxTracker
|
||||
blockchain *core.BlockChain
|
||||
|
||||
handler *handler
|
||||
|
@ -244,7 +244,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
log.Warn("Sanitizing invalid txpool journal time", "provided", rejournal, "updated", time.Second)
|
||||
rejournal = time.Second
|
||||
}
|
||||
eth.localTxTracker = tracker.New(config.TxPool.Journal, rejournal, eth.blockchain.Config(), eth.txPool)
|
||||
eth.localTxTracker = locals.New(config.TxPool.Journal, rejournal, eth.blockchain.Config(), eth.txPool)
|
||||
stack.RegisterLifecycle(eth.localTxTracker)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue