Skip to content

Commit

Permalink
[rpc] Simplify Pending txn (#2065)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxfactorial committed Jan 11, 2020
1 parent 97ebb37 commit b2210fa
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions internal/hmyapi/transactionpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,28 +270,14 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha
}

// 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) {
pending, err := s.b.GetPoolTransactions()
if err != nil {
return nil, err
}
accounts := make(map[common.Address]struct{})
for _, wallet := range s.b.AccountManager().Wallets() {
for _, account := range wallet.Accounts() {
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))
}
transactions := make([]*RPCTransaction, len(pending))
for i := range pending {
transactions[i] = newRPCPendingTransaction(pending[i])
}
return transactions, nil
}
Expand Down

0 comments on commit b2210fa

Please sign in to comment.