Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
90829a04
Unverified
Commit
90829a04
authored
Jun 12, 2018
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal/ethapi: reduce pendingTransactions to O(txs+accs) from O(txs*accs)
parent
f9919959
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
api.go
internal/ethapi/api.go
+9
-4
No files found.
internal/ethapi/api.go
View file @
90829a04
...
@@ -1301,14 +1301,19 @@ func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args Sen
...
@@ -1301,14 +1301,19 @@ func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args Sen
return
&
SignTransactionResult
{
data
,
tx
},
nil
return
&
SignTransactionResult
{
data
,
tx
},
nil
}
}
// PendingTransactions returns the transactions that are in the transaction pool
and have a from address that is one of
// PendingTransactions returns the transactions that are in the transaction pool
// the accounts this node manages.
//
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
{})
for
_
,
wallet
:=
range
s
.
b
.
AccountManager
()
.
Wallets
()
{
for
_
,
account
:=
range
wallet
.
Accounts
()
{
accounts
[
account
.
Address
]
=
struct
{}{}
}
}
transactions
:=
make
([]
*
RPCTransaction
,
0
,
len
(
pending
))
transactions
:=
make
([]
*
RPCTransaction
,
0
,
len
(
pending
))
for
_
,
tx
:=
range
pending
{
for
_
,
tx
:=
range
pending
{
var
signer
types
.
Signer
=
types
.
HomesteadSigner
{}
var
signer
types
.
Signer
=
types
.
HomesteadSigner
{}
...
@@ -1316,7 +1321,7 @@ func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, err
...
@@ -1316,7 +1321,7 @@ func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, err
signer
=
types
.
NewEIP155Signer
(
tx
.
ChainId
())
signer
=
types
.
NewEIP155Signer
(
tx
.
ChainId
())
}
}
from
,
_
:=
types
.
Sender
(
signer
,
tx
)
from
,
_
:=
types
.
Sender
(
signer
,
tx
)
if
_
,
e
rr
:=
s
.
b
.
AccountManager
()
.
Find
(
accounts
.
Account
{
Address
:
from
});
err
==
nil
{
if
_
,
e
xists
:=
accounts
[
from
];
exists
{
transactions
=
append
(
transactions
,
newRPCPendingTransaction
(
tx
))
transactions
=
append
(
transactions
,
newRPCPendingTransaction
(
tx
))
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment