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
a9f9a594
Commit
a9f9a594
authored
Aug 22, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extra checks
parent
42d43147
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
block_pool.go
block_pool.go
+9
-5
No files found.
block_pool.go
View file @
a9f9a594
...
...
@@ -49,11 +49,11 @@ func (self *BlockPool) AddHash(hash []byte) {
}
}
func
(
self
*
BlockPool
)
SetBlock
(
b
*
ethchain
.
Block
)
{
func
(
self
*
BlockPool
)
SetBlock
(
b
*
ethchain
.
Block
,
peer
*
Peer
)
{
hash
:=
string
(
b
.
Hash
())
if
self
.
pool
[
string
(
hash
)
]
==
nil
{
self
.
pool
[
hash
]
=
&
block
{
nil
,
nil
}
if
self
.
pool
[
hash
]
==
nil
{
self
.
pool
[
hash
]
=
&
block
{
peer
,
nil
}
}
self
.
pool
[
hash
]
.
block
=
b
...
...
@@ -65,6 +65,10 @@ func (self *BlockPool) CheckLinkAndProcess(f func(block *ethchain.Block)) bool {
if
self
.
IsLinked
()
{
for
i
,
hash
:=
range
self
.
hashPool
{
if
self
.
pool
[
string
(
hash
)]
==
nil
{
continue
}
block
:=
self
.
pool
[
string
(
hash
)]
.
block
if
block
!=
nil
{
f
(
block
)
...
...
@@ -84,7 +88,7 @@ func (self *BlockPool) CheckLinkAndProcess(f func(block *ethchain.Block)) bool {
}
func
(
self
*
BlockPool
)
IsLinked
()
bool
{
if
len
(
self
.
hashPool
)
==
0
{
if
len
(
self
.
hashPool
)
==
0
||
self
.
pool
[
string
(
self
.
hashPool
[
0
])]
==
nil
{
return
false
}
...
...
@@ -104,7 +108,7 @@ func (self *BlockPool) Take(amount int, peer *Peer) (hashes [][]byte) {
j
:=
0
for
i
:=
0
;
i
<
len
(
self
.
hashPool
)
&&
j
<
num
;
i
++
{
hash
:=
string
(
self
.
hashPool
[
i
])
if
self
.
pool
[
hash
]
.
peer
==
nil
||
self
.
pool
[
hash
]
.
peer
==
peer
{
if
self
.
pool
[
hash
]
!=
nil
&&
(
self
.
pool
[
hash
]
.
peer
==
nil
||
self
.
pool
[
hash
]
.
peer
==
peer
)
&&
self
.
pool
[
hash
]
.
block
==
nil
{
self
.
pool
[
hash
]
.
peer
=
peer
hashes
=
append
(
hashes
,
self
.
hashPool
[
i
])
...
...
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