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
165f53fc
Unverified
Commit
165f53fc
authored
Jan 07, 2021
by
gary rong
Committed by
GitHub
Jan 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
les: remove transaction propagation limits (#22125)
parent
d3952898
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
22 deletions
+8
-22
txrelay.go
les/txrelay.go
+8
-22
No files found.
les/txrelay.go
View file @
165f53fc
...
@@ -25,13 +25,8 @@ import (
...
@@ -25,13 +25,8 @@ import (
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rlp"
)
)
type
ltrInfo
struct
{
tx
*
types
.
Transaction
sentTo
map
[
*
serverPeer
]
struct
{}
}
type
lesTxRelay
struct
{
type
lesTxRelay
struct
{
txSent
map
[
common
.
Hash
]
*
ltrInfo
txSent
map
[
common
.
Hash
]
*
types
.
Transaction
txPending
map
[
common
.
Hash
]
struct
{}
txPending
map
[
common
.
Hash
]
struct
{}
peerList
[]
*
serverPeer
peerList
[]
*
serverPeer
peerStartPos
int
peerStartPos
int
...
@@ -43,7 +38,7 @@ type lesTxRelay struct {
...
@@ -43,7 +38,7 @@ type lesTxRelay struct {
func
newLesTxRelay
(
ps
*
serverPeerSet
,
retriever
*
retrieveManager
)
*
lesTxRelay
{
func
newLesTxRelay
(
ps
*
serverPeerSet
,
retriever
*
retrieveManager
)
*
lesTxRelay
{
r
:=
&
lesTxRelay
{
r
:=
&
lesTxRelay
{
txSent
:
make
(
map
[
common
.
Hash
]
*
ltrInfo
),
txSent
:
make
(
map
[
common
.
Hash
]
*
types
.
Transaction
),
txPending
:
make
(
map
[
common
.
Hash
]
struct
{}),
txPending
:
make
(
map
[
common
.
Hash
]
struct
{}),
retriever
:
retriever
,
retriever
:
retriever
,
stop
:
make
(
chan
struct
{}),
stop
:
make
(
chan
struct
{}),
...
@@ -80,8 +75,7 @@ func (ltrx *lesTxRelay) unregisterPeer(p *serverPeer) {
...
@@ -80,8 +75,7 @@ func (ltrx *lesTxRelay) unregisterPeer(p *serverPeer) {
}
}
}
}
// send sends a list of transactions to at most a given number of peers at
// send sends a list of transactions to at most a given number of peers.
// once, never resending any particular transaction to the same peer twice
func
(
ltrx
*
lesTxRelay
)
send
(
txs
types
.
Transactions
,
count
int
)
{
func
(
ltrx
*
lesTxRelay
)
send
(
txs
types
.
Transactions
,
count
int
)
{
sendTo
:=
make
(
map
[
*
serverPeer
]
types
.
Transactions
)
sendTo
:=
make
(
map
[
*
serverPeer
]
types
.
Transactions
)
...
@@ -92,26 +86,18 @@ func (ltrx *lesTxRelay) send(txs types.Transactions, count int) {
...
@@ -92,26 +86,18 @@ func (ltrx *lesTxRelay) send(txs types.Transactions, count int) {
for
_
,
tx
:=
range
txs
{
for
_
,
tx
:=
range
txs
{
hash
:=
tx
.
Hash
()
hash
:=
tx
.
Hash
()
ltr
,
ok
:=
ltrx
.
txSent
[
hash
]
_
,
ok
:=
ltrx
.
txSent
[
hash
]
if
!
ok
{
if
!
ok
{
ltr
=
&
ltrInfo
{
ltrx
.
txSent
[
hash
]
=
tx
tx
:
tx
,
sentTo
:
make
(
map
[
*
serverPeer
]
struct
{}),
}
ltrx
.
txSent
[
hash
]
=
ltr
ltrx
.
txPending
[
hash
]
=
struct
{}{}
ltrx
.
txPending
[
hash
]
=
struct
{}{}
}
}
if
len
(
ltrx
.
peerList
)
>
0
{
if
len
(
ltrx
.
peerList
)
>
0
{
cnt
:=
count
cnt
:=
count
pos
:=
ltrx
.
peerStartPos
pos
:=
ltrx
.
peerStartPos
for
{
for
{
peer
:=
ltrx
.
peerList
[
pos
]
peer
:=
ltrx
.
peerList
[
pos
]
if
_
,
ok
:=
ltr
.
sentTo
[
peer
];
!
ok
{
sendTo
[
peer
]
=
append
(
sendTo
[
peer
],
tx
)
sendTo
[
peer
]
=
append
(
sendTo
[
peer
],
tx
)
cnt
--
ltr
.
sentTo
[
peer
]
=
struct
{}{}
cnt
--
}
if
cnt
==
0
{
if
cnt
==
0
{
break
// sent it to the desired number of peers
break
// sent it to the desired number of peers
}
}
...
@@ -174,7 +160,7 @@ func (ltrx *lesTxRelay) NewHead(head common.Hash, mined []common.Hash, rollback
...
@@ -174,7 +160,7 @@ func (ltrx *lesTxRelay) NewHead(head common.Hash, mined []common.Hash, rollback
txs
:=
make
(
types
.
Transactions
,
len
(
ltrx
.
txPending
))
txs
:=
make
(
types
.
Transactions
,
len
(
ltrx
.
txPending
))
i
:=
0
i
:=
0
for
hash
:=
range
ltrx
.
txPending
{
for
hash
:=
range
ltrx
.
txPending
{
txs
[
i
]
=
ltrx
.
txSent
[
hash
]
.
tx
txs
[
i
]
=
ltrx
.
txSent
[
hash
]
i
++
i
++
}
}
ltrx
.
send
(
txs
,
1
)
ltrx
.
send
(
txs
,
1
)
...
...
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