aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ethapi/api.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-06-27 23:28:34 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-09-02 19:12:03 +0800
commit795b70423eac7180ab85b735f64aae9d6a10449d (patch)
treeafa669325907e0c56c9898010fbbed3695497c9c /internal/ethapi/api.go
parent49227f65ff5ae42d47dfb65eaf88d38790543b06 (diff)
downloadgo-tangerine-795b70423eac7180ab85b735f64aae9d6a10449d.tar.gz
go-tangerine-795b70423eac7180ab85b735f64aae9d6a10449d.tar.zst
go-tangerine-795b70423eac7180ab85b735f64aae9d6a10449d.zip
core, eth, miner: only retain 1 tx/nonce, remove bad ones
Diffstat (limited to 'internal/ethapi/api.go')
-rw-r--r--internal/ethapi/api.go60
1 files changed, 24 insertions, 36 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 184b5831f..0fba55ae8 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -100,32 +100,26 @@ func NewPublicTxPoolAPI(b Backend) *PublicTxPoolAPI {
}
// Content returns the transactions contained within the transaction pool.
-func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string][]*RPCTransaction {
- content := map[string]map[string]map[string][]*RPCTransaction{
- "pending": make(map[string]map[string][]*RPCTransaction),
- "queued": make(map[string]map[string][]*RPCTransaction),
+func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction {
+ content := map[string]map[string]map[string]*RPCTransaction{
+ "pending": make(map[string]map[string]*RPCTransaction),
+ "queued": make(map[string]map[string]*RPCTransaction),
}
pending, queue := s.b.TxPoolContent()
// Flatten the pending transactions
- for account, batches := range pending {
- dump := make(map[string][]*RPCTransaction)
- for nonce, txs := range batches {
- nonce := fmt.Sprintf("%d", nonce)
- for _, tx := range txs {
- dump[nonce] = append(dump[nonce], newRPCPendingTransaction(tx))
- }
+ for account, txs := range pending {
+ dump := make(map[string]*RPCTransaction)
+ for nonce, tx := range txs {
+ dump[fmt.Sprintf("%d", nonce)] = newRPCPendingTransaction(tx)
}
content["pending"][account.Hex()] = dump
}
// Flatten the queued transactions
- for account, batches := range queue {
- dump := make(map[string][]*RPCTransaction)
- for nonce, txs := range batches {
- nonce := fmt.Sprintf("%d", nonce)
- for _, tx := range txs {
- dump[nonce] = append(dump[nonce], newRPCPendingTransaction(tx))
- }
+ for account, txs := range queue {
+ dump := make(map[string]*RPCTransaction)
+ for nonce, tx := range txs {
+ dump[fmt.Sprintf("%d", nonce)] = newRPCPendingTransaction(tx)
}
content["queued"][account.Hex()] = dump
}
@@ -143,10 +137,10 @@ func (s *PublicTxPoolAPI) Status() map[string]*rpc.HexNumber {
// Inspect retrieves the content of the transaction pool and flattens it into an
// easily inspectable list.
-func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string][]string {
- content := map[string]map[string]map[string][]string{
- "pending": make(map[string]map[string][]string),
- "queued": make(map[string]map[string][]string),
+func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string]string {
+ content := map[string]map[string]map[string]string{
+ "pending": make(map[string]map[string]string),
+ "queued": make(map[string]map[string]string),
}
pending, queue := s.b.TxPoolContent()
@@ -158,24 +152,18 @@ func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string][]string {
return fmt.Sprintf("contract creation: %v wei + %v × %v gas", tx.Value(), tx.Gas(), tx.GasPrice())
}
// Flatten the pending transactions
- for account, batches := range pending {
- dump := make(map[string][]string)
- for nonce, txs := range batches {
- nonce := fmt.Sprintf("%d", nonce)
- for _, tx := range txs {
- dump[nonce] = append(dump[nonce], format(tx))
- }
+ for account, txs := range pending {
+ dump := make(map[string]string)
+ for nonce, tx := range txs {
+ dump[fmt.Sprintf("%d", nonce)] = format(tx)
}
content["pending"][account.Hex()] = dump
}
// Flatten the queued transactions
- for account, batches := range queue {
- dump := make(map[string][]string)
- for nonce, txs := range batches {
- nonce := fmt.Sprintf("%d", nonce)
- for _, tx := range txs {
- dump[nonce] = append(dump[nonce], format(tx))
- }
+ for account, txs := range queue {
+ dump := make(map[string]string)
+ for nonce, tx := range txs {
+ dump[fmt.Sprintf("%d", nonce)] = format(tx)
}
content["queued"][account.Hex()] = dump
}