core, eth, les: polish txpool API around local/remote txs
This commit is contained in:
@ -119,8 +119,7 @@ func (b *EthApiBackend) SendTx(ctx context.Context, signedTx *types.Transaction)
|
||||
b.eth.txMu.Lock()
|
||||
defer b.eth.txMu.Unlock()
|
||||
|
||||
b.eth.txPool.SetLocal(signedTx)
|
||||
return b.eth.txPool.Add(signedTx)
|
||||
return b.eth.txPool.AddLocal(signedTx)
|
||||
}
|
||||
|
||||
func (b *EthApiBackend) RemoveTx(txHash common.Hash) {
|
||||
|
@ -661,7 +661,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
|
||||
}
|
||||
p.MarkTransaction(tx.Hash())
|
||||
}
|
||||
pm.txpool.AddBatch(txs)
|
||||
pm.txpool.AddRemotes(txs)
|
||||
|
||||
default:
|
||||
return errResp(ErrInvalidMsgCode, "%v", msg.Code)
|
||||
|
@ -94,9 +94,9 @@ type testTxPool struct {
|
||||
lock sync.RWMutex // Protects the transaction pool
|
||||
}
|
||||
|
||||
// AddBatch appends a batch of transactions to the pool, and notifies any
|
||||
// AddRemotes appends a batch of transactions to the pool, and notifies any
|
||||
// listeners if the addition channel is non nil
|
||||
func (p *testTxPool) AddBatch(txs []*types.Transaction) error {
|
||||
func (p *testTxPool) AddRemotes(txs []*types.Transaction) error {
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
|
||||
|
@ -94,8 +94,8 @@ var errorToString = map[int]string{
|
||||
}
|
||||
|
||||
type txPool interface {
|
||||
// AddBatch should add the given transactions to the pool.
|
||||
AddBatch([]*types.Transaction) error
|
||||
// AddRemotes should add the given transactions to the pool.
|
||||
AddRemotes([]*types.Transaction) error
|
||||
|
||||
// Pending should return pending transactions.
|
||||
// The slice should be modifiable by the caller.
|
||||
|
@ -130,7 +130,7 @@ func testSendTransactions(t *testing.T, protocol int) {
|
||||
for nonce := range alltxs {
|
||||
alltxs[nonce] = newTestTransaction(testAccount, uint64(nonce), txsize)
|
||||
}
|
||||
pm.txpool.AddBatch(alltxs)
|
||||
pm.txpool.AddRemotes(alltxs)
|
||||
|
||||
// Connect several peers. They should all receive the pending transactions.
|
||||
var wg sync.WaitGroup
|
||||
|
Reference in New Issue
Block a user