aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-07-10 17:43:23 +0800
committerGitHub <noreply@github.com>2017-07-10 17:43:23 +0800
commit4f7a38001f7137972303421a11d49b0745450a3a (patch)
tree0a486e90fd8cf7d2ab161610b79a2251483895c0 /eth
parent65f0e905ddda9be97368839b67be5754b33a0eea (diff)
parent34ec9913f628180d0ace740abfe1362995879c93 (diff)
downloadgo-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar
go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.gz
go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.bz2
go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.lz
go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.xz
go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.tar.zst
go-tangerine-4f7a38001f7137972303421a11d49b0745450a3a.zip
Merge pull request #14737 from holiman/txpool_localaccounts
Txpool localaccounts
Diffstat (limited to 'eth')
-rw-r--r--eth/api_backend.go25
-rw-r--r--eth/backend.go1
-rw-r--r--eth/handler.go2
-rw-r--r--eth/helper_test.go4
-rw-r--r--eth/protocol.go4
-rw-r--r--eth/protocol_test.go2
6 files changed, 7 insertions, 31 deletions
diff --git a/eth/api_backend.go b/eth/api_backend.go
index 166b5084d..7ef7c030d 100644
--- a/eth/api_backend.go
+++ b/eth/api_backend.go
@@ -116,29 +116,18 @@ func (b *EthApiBackend) GetEVM(ctx context.Context, msg core.Message, state *sta
}
func (b *EthApiBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error {
- 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) {
- b.eth.txMu.Lock()
- defer b.eth.txMu.Unlock()
-
b.eth.txPool.Remove(txHash)
}
func (b *EthApiBackend) GetPoolTransactions() (types.Transactions, error) {
- b.eth.txMu.Lock()
- defer b.eth.txMu.Unlock()
-
pending, err := b.eth.txPool.Pending()
if err != nil {
return nil, err
}
-
var txs types.Transactions
for _, batch := range pending {
txs = append(txs, batch...)
@@ -147,30 +136,18 @@ func (b *EthApiBackend) GetPoolTransactions() (types.Transactions, error) {
}
func (b *EthApiBackend) GetPoolTransaction(hash common.Hash) *types.Transaction {
- b.eth.txMu.Lock()
- defer b.eth.txMu.Unlock()
-
return b.eth.txPool.Get(hash)
}
func (b *EthApiBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) {
- b.eth.txMu.Lock()
- defer b.eth.txMu.Unlock()
-
return b.eth.txPool.State().GetNonce(addr), nil
}
func (b *EthApiBackend) Stats() (pending int, queued int) {
- b.eth.txMu.Lock()
- defer b.eth.txMu.Unlock()
-
return b.eth.txPool.Stats()
}
func (b *EthApiBackend) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) {
- b.eth.txMu.Lock()
- defer b.eth.txMu.Unlock()
-
return b.eth.TxPool().Content()
}
diff --git a/eth/backend.go b/eth/backend.go
index 75e0e737b..78478e86e 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -63,7 +63,6 @@ type Ethereum struct {
stopDbUpgrade func() // stop chain db sequential key upgrade
// Handlers
txPool *core.TxPool
- txMu sync.Mutex
blockchain *core.BlockChain
protocolManager *ProtocolManager
lesServer LesServer
diff --git a/eth/handler.go b/eth/handler.go
index b2422d71c..6c6449340 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -658,7 +658,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)
diff --git a/eth/helper_test.go b/eth/helper_test.go
index 0260b9d77..546478a3e 100644
--- a/eth/helper_test.go
+++ b/eth/helper_test.go
@@ -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()
diff --git a/eth/protocol.go b/eth/protocol.go
index 4bc8bee72..376e4663e 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -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.
diff --git a/eth/protocol_test.go b/eth/protocol_test.go
index 2056ee0a8..d3a44ae91 100644
--- a/eth/protocol_test.go
+++ b/eth/protocol_test.go
@@ -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