Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
7a18a393
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7a18a393
编写于
4月 04, 2015
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
prevent deadlock
上级
f9488cb7
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
12 addition
and
17 deletion
+12
-17
blockpool/blockpool.go
blockpool/blockpool.go
+2
-0
core/block_processor.go
core/block_processor.go
+4
-4
core/chain_manager.go
core/chain_manager.go
+6
-13
未找到文件。
blockpool/blockpool.go
浏览文件 @
7a18a393
...
@@ -622,6 +622,8 @@ func (self *BlockPool) AddBlock(block *types.Block, peerId string) {
...
@@ -622,6 +622,8 @@ func (self *BlockPool) AddBlock(block *types.Block, peerId string) {
entry
:=
self
.
get
(
hash
)
entry
:=
self
.
get
(
hash
)
fmt
.
Println
(
"block number"
,
block
.
Number
())
defer
fmt
.
Println
(
"AddBlock done"
)
// a peer's current head block is appearing the first time
// a peer's current head block is appearing the first time
if
hash
==
sender
.
currentBlockHash
{
if
hash
==
sender
.
currentBlockHash
{
if
sender
.
currentBlock
==
nil
{
if
sender
.
currentBlock
==
nil
{
...
...
core/block_processor.go
浏览文件 @
7a18a393
...
@@ -268,15 +268,15 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
...
@@ -268,15 +268,15 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
return
BlockNumberErr
return
BlockNumberErr
}
}
if
block
.
Time
<=
parent
.
Time
{
return
BlockEqualTSErr
//ValidationError("Block timestamp equal or less than previous block (%v - %v)", block.Time, parent.Time)
}
// Verify the nonce of the block. Return an error if it's not valid
// Verify the nonce of the block. Return an error if it's not valid
if
!
sm
.
Pow
.
Verify
(
types
.
NewBlockWithHeader
(
block
))
{
if
!
sm
.
Pow
.
Verify
(
types
.
NewBlockWithHeader
(
block
))
{
return
ValidationError
(
"Block's nonce is invalid (= %x)"
,
block
.
Nonce
)
return
ValidationError
(
"Block's nonce is invalid (= %x)"
,
block
.
Nonce
)
}
}
if
block
.
Time
<=
parent
.
Time
{
return
BlockEqualTSErr
//ValidationError("Block timestamp equal or less than previous block (%v - %v)", block.Time, parent.Time)
}
return
nil
return
nil
}
}
...
...
core/chain_manager.go
浏览文件 @
7a18a393
...
@@ -437,21 +437,20 @@ type queueEvent struct {
...
@@ -437,21 +437,20 @@ type queueEvent struct {
}
}
func
(
self
*
ChainManager
)
procFutureBlocks
()
{
func
(
self
*
ChainManager
)
procFutureBlocks
()
{
self
.
futureBlocks
.
mu
.
Lock
()
blocks
:=
make
([]
*
types
.
Block
,
len
(
self
.
futureBlocks
.
blocks
))
blocks
:=
make
([]
*
types
.
Block
,
len
(
self
.
futureBlocks
.
blocks
))
for
i
,
hash
:=
range
self
.
futureBlocks
.
hashes
{
for
i
,
hash
:=
range
self
.
futureBlocks
.
hashes
{
blocks
[
i
]
=
self
.
futureBlocks
.
Get
(
hash
)
blocks
[
i
]
=
self
.
futureBlocks
.
Get
(
hash
)
}
}
self
.
futureBlocks
.
mu
.
Unlock
()
types
.
BlockBy
(
types
.
Number
)
.
Sort
(
blocks
)
types
.
BlockBy
(
types
.
Number
)
.
Sort
(
blocks
)
self
.
InsertChain
(
blocks
)
self
.
InsertChain
(
blocks
)
}
}
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
error
{
func
(
self
*
ChainManager
)
InsertChain
(
chain
types
.
Blocks
)
error
{
//self.tsmu.Lock()
if
len
(
chain
)
>
0
{
//defer self.tsmu.Unlock()
fmt
.
Println
(
"insert chain"
,
len
(
chain
))
defer
fmt
.
Println
(
"insert chain done"
)
}
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
var
queue
=
make
([]
interface
{},
len
(
chain
))
var
queue
=
make
([]
interface
{},
len
(
chain
))
...
@@ -472,23 +471,17 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
...
@@ -472,23 +471,17 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
// Do not penelise on future block. We'll need a block queue eventually that will queue
// Do not penelise on future block. We'll need a block queue eventually that will queue
// future block for future use
// future block for future use
if
err
==
BlockFutureErr
{
if
err
==
BlockFutureErr
{
fmt
.
Println
(
"added future block"
,
block
.
Number
())
self
.
futureBlocks
.
Push
(
block
)
self
.
futureBlocks
.
Push
(
block
)
continue
continue
}
}
if
IsParentErr
(
err
)
&&
self
.
futureBlocks
.
Has
(
block
.
ParentHash
())
{
if
IsParentErr
(
err
)
&&
self
.
futureBlocks
.
Has
(
block
.
ParentHash
())
{
fmt
.
Println
(
"added future block 2"
,
block
.
Number
())
self
.
futureBlocks
.
Push
(
block
)
self
.
futureBlocks
.
Push
(
block
)
continue
continue
}
}
/*
if err == BlockEqualTSErr {
//queue[i] = ChainSideEvent{block, logs}
// XXX silently discard it?
continue
}
*/
h
:=
block
.
Header
()
h
:=
block
.
Header
()
chainlogger
.
Errorf
(
"INVALID block #%v (%x)
\n
"
,
h
.
Number
,
h
.
Hash
()
.
Bytes
()[
:
4
])
chainlogger
.
Errorf
(
"INVALID block #%v (%x)
\n
"
,
h
.
Number
,
h
.
Hash
()
.
Bytes
()[
:
4
])
chainlogger
.
Errorln
(
err
)
chainlogger
.
Errorln
(
err
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录