core/txpool/tracker: address review concerns (pkg name + unused)
This commit is contained in:
parent
888546725e
commit
82c9789a9a
|
@ -1693,13 +1693,6 @@ func (p *BlobPool) ContentFrom(addr common.Address) ([]*types.Transaction, []*ty
|
|||
return []*types.Transaction{}, []*types.Transaction{}
|
||||
}
|
||||
|
||||
// Locals retrieves the accounts currently considered local by the pool.
|
||||
//
|
||||
// There is no notion of local accounts in the blob pool.
|
||||
func (p *BlobPool) Locals() []common.Address {
|
||||
return []common.Address{}
|
||||
}
|
||||
|
||||
// Status returns the known status (unknown/pending/queued) of a transaction
|
||||
// identified by their hashes.
|
||||
func (p *BlobPool) Status(hash common.Hash) txpool.TxStatus {
|
||||
|
|
|
@ -2245,34 +2245,6 @@ func benchmarkBatchInsert(b *testing.B, size int) {
|
|||
}
|
||||
}
|
||||
|
||||
func BenchmarkInsertRemoteWithAllLocals(b *testing.B) {
|
||||
// Allocate keys for testing
|
||||
key, _ := crypto.GenerateKey()
|
||||
account := crypto.PubkeyToAddress(key.PublicKey)
|
||||
|
||||
remoteKey, _ := crypto.GenerateKey()
|
||||
remoteAddr := crypto.PubkeyToAddress(remoteKey.PublicKey)
|
||||
|
||||
remotes := make([]*types.Transaction, 1000)
|
||||
for i := 0; i < len(remotes); i++ {
|
||||
remotes[i] = pricedTransaction(uint64(i), 100000, big.NewInt(2), remoteKey) // Higher gasprice
|
||||
}
|
||||
// Benchmark importing the transactions into the queue
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
b.StopTimer()
|
||||
pool, _ := setupPool()
|
||||
testAddBalance(pool, account, big.NewInt(100000000))
|
||||
b.StartTimer()
|
||||
// Assign a high enough balance for testing
|
||||
testAddBalance(pool, remoteAddr, big.NewInt(100000000))
|
||||
for i := 0; i < len(remotes); i++ {
|
||||
pool.addRemotes([]*types.Transaction{remotes[i]})
|
||||
}
|
||||
pool.Close()
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmarks the speed of batch transaction insertion in case of multiple accounts.
|
||||
func BenchmarkMultiAccountBatchInsert(b *testing.B) {
|
||||
// Generate a batch of transactions to enqueue into the pool
|
||||
|
|
|
@ -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 tracking
|
||||
package tracker
|
||||
|
||||
import (
|
||||
"errors"
|
|
@ -15,7 +15,7 @@
|
|||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Package legacypool implements the normal EVM execution transaction pool.
|
||||
package tracking
|
||||
package tracker
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
@ -48,19 +48,18 @@ type TxTracker struct {
|
|||
signer types.Signer
|
||||
|
||||
shutdownCh chan struct{}
|
||||
triggerCh chan struct{}
|
||||
mu sync.Mutex
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
func NewTxTracker(journalPath string, journalTime time.Duration, chainConfig *params.ChainConfig, next *txpool.TxPool) *TxTracker {
|
||||
// New creates a new TxTracker
|
||||
func New(journalPath string, journalTime time.Duration, chainConfig *params.ChainConfig, next *txpool.TxPool) *TxTracker {
|
||||
signer := types.LatestSigner(chainConfig)
|
||||
pool := &TxTracker{
|
||||
all: make(map[common.Hash]*types.Transaction),
|
||||
byAddr: make(map[common.Address]*legacypool.SortedMap),
|
||||
signer: signer,
|
||||
shutdownCh: make(chan struct{}),
|
||||
triggerCh: make(chan struct{}),
|
||||
pool: next,
|
||||
}
|
||||
if journalPath != "" {
|
||||
|
@ -148,7 +147,7 @@ func (tracker *TxTracker) Start() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Start implements node.Lifecycle interface
|
||||
// Stop implements node.Lifecycle interface
|
||||
// Stop terminates all goroutines belonging to the service, blocking until they
|
||||
// are all terminated.
|
||||
func (tracker *TxTracker) Stop() error {
|
||||
|
@ -157,13 +156,6 @@ func (tracker *TxTracker) Stop() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// TriggerRecheck triggers a recheck, whereby the tracker potentially resubmits
|
||||
// transactions to the tx pool. This method is mainly useful for test purposes,
|
||||
// in order to speed up the process.
|
||||
func (tracker *TxTracker) TriggerRecheck() {
|
||||
tracker.triggerCh <- struct{}{}
|
||||
}
|
||||
|
||||
func (tracker *TxTracker) loop() {
|
||||
defer tracker.wg.Done()
|
||||
if tracker.journal != nil {
|
||||
|
@ -180,11 +172,6 @@ func (tracker *TxTracker) loop() {
|
|||
select {
|
||||
case <-tracker.shutdownCh:
|
||||
return
|
||||
case <-tracker.triggerCh:
|
||||
resubmits, _ := tracker.recheck(false)
|
||||
if len(resubmits) > 0 {
|
||||
tracker.pool.Add(resubmits, false)
|
||||
}
|
||||
case <-t.C:
|
||||
checkJournal := tracker.journal != nil && time.Since(lastJournal) > tracker.rejournal
|
||||
resubmits, rejournal := tracker.recheck(checkJournal)
|
|
@ -23,6 +23,7 @@ import (
|
|||
"math/big"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
@ -35,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/tracking"
|
||||
"github.com/ethereum/go-ethereum/core/txpool/tracker"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
|
@ -70,7 +71,7 @@ type Ethereum struct {
|
|||
// core protocol objects
|
||||
config *ethconfig.Config
|
||||
txPool *txpool.TxPool
|
||||
localTxTracker *tracking.TxTracker
|
||||
localTxTracker *tracker.TxTracker
|
||||
blockchain *core.BlockChain
|
||||
|
||||
handler *handler
|
||||
|
@ -238,12 +239,12 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
eth.txPool, err = txpool.New(config.TxPool.PriceLimit, eth.blockchain, []txpool.SubPool{legacyPool, blobPool})
|
||||
|
||||
if !config.TxPool.NoLocals {
|
||||
// TODO!
|
||||
// We also need to handle config.Locals, the accounts that are
|
||||
// to be treated as locals, regardless of how they arrive to geth.
|
||||
eth.localTxTracker = tracking.NewTxTracker(config.TxPool.Journal,
|
||||
config.TxPool.Rejournal,
|
||||
eth.blockchain.Config(), eth.txPool)
|
||||
rejournal := config.TxPool.Rejournal
|
||||
if rejournal < time.Second {
|
||||
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)
|
||||
stack.RegisterLifecycle(eth.localTxTracker)
|
||||
}
|
||||
|
||||
|
@ -340,8 +341,7 @@ func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) {
|
|||
s.blockchain.ResetWithGenesisBlock(gb)
|
||||
}
|
||||
|
||||
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
|
||||
func (s *Ethereum) Tracker() *tracking.TxTracker { return s.localTxTracker }
|
||||
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
|
||||
|
||||
func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager }
|
||||
func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain }
|
||||
|
|
Loading…
Reference in New Issue