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
66b29899
Commit
66b29899
authored
Mar 20, 2015
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use common.Hash as pool key, no string conversion needed
parent
d7564a9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
blockpool.go
blockpool/blockpool.go
+6
-6
section.go
blockpool/section.go
+2
-2
No files found.
blockpool/blockpool.go
View file @
66b29899
...
...
@@ -157,8 +157,8 @@ type BlockPool struct {
tdSub
event
.
Subscription
// subscription to core.ChainHeadEvent
td
*
big
.
Int
// our own total difficulty
pool
map
[
string
]
*
entry
// the actual blockpool
peers
*
peers
// peers manager in peers.go
pool
map
[
common
.
Hash
]
*
entry
// the actual blockpool
peers
*
peers
// peers manager in peers.go
status
*
status
// info about blockpool (UI interface) in status.go
...
...
@@ -210,7 +210,7 @@ func (self *BlockPool) Start() {
self
.
hashSlicePool
=
make
(
chan
[]
common
.
Hash
,
150
)
self
.
status
=
newStatus
()
self
.
quit
=
make
(
chan
bool
)
self
.
pool
=
make
(
map
[
string
]
*
entry
)
self
.
pool
=
make
(
map
[
common
.
Hash
]
*
entry
)
self
.
running
=
true
self
.
peers
=
&
peers
{
...
...
@@ -789,13 +789,13 @@ func (self *BlockPool) getChild(sec *section) *section {
func
(
self
*
BlockPool
)
get
(
hash
common
.
Hash
)
*
entry
{
self
.
lock
.
RLock
()
defer
self
.
lock
.
RUnlock
()
return
self
.
pool
[
hash
.
Str
()
]
return
self
.
pool
[
hash
]
}
func
(
self
*
BlockPool
)
set
(
hash
common
.
Hash
,
e
*
entry
)
{
self
.
lock
.
Lock
()
defer
self
.
lock
.
Unlock
()
self
.
pool
[
hash
.
Str
()
]
=
e
self
.
pool
[
hash
]
=
e
}
// accessor and setter for total difficulty
...
...
@@ -817,7 +817,7 @@ func (self *BlockPool) remove(sec *section) {
defer
self
.
lock
.
Unlock
()
for
_
,
node
:=
range
sec
.
nodes
{
delete
(
self
.
pool
,
node
.
hash
.
Str
()
)
delete
(
self
.
pool
,
node
.
hash
)
}
if
sec
.
initialised
&&
sec
.
poolRootIndex
!=
0
{
self
.
status
.
lock
.
Lock
()
...
...
blockpool/section.go
View file @
66b29899
...
...
@@ -106,7 +106,7 @@ func (self *section) addSectionToBlockChain(p *peer) {
var
nodes
[]
*
node
var
n
*
node
var
keys
[]
string
var
keys
[]
common
.
Hash
var
blocks
[]
*
types
.
Block
for
self
.
poolRootIndex
>
0
{
n
=
self
.
nodes
[
self
.
poolRootIndex
-
1
]
...
...
@@ -117,7 +117,7 @@ func (self *section) addSectionToBlockChain(p *peer) {
break
}
self
.
poolRootIndex
--
keys
=
append
(
keys
,
n
.
hash
.
Str
()
)
keys
=
append
(
keys
,
n
.
hash
)
blocks
=
append
(
blocks
,
block
)
nodes
=
append
(
nodes
,
n
)
}
...
...
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