[rpc] Simplify Pending txn (#2065)

pull/2081/head
Edgar Aroutiounian 5 years ago committed by GitHub
parent 7bbd162425
commit b033a6d45e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      internal/hmyapi/transactionpool.go

@ -333,28 +333,14 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha
} }
// PendingTransactions returns the transactions that are in the transaction pool // PendingTransactions returns the transactions that are in the transaction pool
// and have a from address that is one of the accounts this node manages.
func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, error) { func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, error) {
pending, err := s.b.GetPoolTransactions() pending, err := s.b.GetPoolTransactions()
if err != nil { if err != nil {
return nil, err return nil, err
} }
accounts := make(map[common.Address]struct{}) transactions := make([]*RPCTransaction, len(pending))
for _, wallet := range s.b.AccountManager().Wallets() { for i := range pending {
for _, account := range wallet.Accounts() { transactions[i] = newRPCPendingTransaction(pending[i])
accounts[account.Address] = struct{}{}
}
}
transactions := make([]*RPCTransaction, 0, len(pending))
for _, tx := range pending {
var signer types.Signer = types.HomesteadSigner{}
if tx.Protected() {
signer = types.NewEIP155Signer(tx.ChainID())
}
from, _ := types.Sender(signer, tx)
if _, exists := accounts[from]; exists {
transactions = append(transactions, newRPCPendingTransaction(tx))
}
} }
return transactions, nil return transactions, nil
} }

Loading…
Cancel
Save