Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
434e4b31
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,体验更适合开发者的 AI 搜索 >>
提交
434e4b31
编写于
3月 15, 2016
作者:
L
Leif Jurvetson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core, eth: replace reorganiz with reorganis
上级
06fe6310
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
8 addition
and
8 deletion
+8
-8
core/blockchain.go
core/blockchain.go
+1
-1
core/blockchain_test.go
core/blockchain_test.go
+4
-4
core/tx_pool_test.go
core/tx_pool_test.go
+1
-1
eth/downloader/downloader.go
eth/downloader/downloader.go
+2
-2
未找到文件。
core/blockchain.go
浏览文件 @
434e4b31
...
...
@@ -775,7 +775,7 @@ func (self *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err
// Second clause in the if statement reduces the vulnerability to selfish mining.
// Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf
if
externTd
.
Cmp
(
localTd
)
>
0
||
(
externTd
.
Cmp
(
localTd
)
==
0
&&
mrand
.
Float64
()
<
0.5
)
{
// Reorgani
z
e the chain if the parent is not the head block
// Reorgani
s
e the chain if the parent is not the head block
if
block
.
ParentHash
()
!=
self
.
currentBlock
.
Hash
()
{
if
err
:=
self
.
reorg
(
self
.
currentBlock
,
block
);
err
!=
nil
{
return
NonStatTy
,
err
...
...
core/blockchain_test.go
浏览文件 @
434e4b31
...
...
@@ -168,7 +168,7 @@ func testHeaderChainImport(chain []*types.Header, blockchain *BlockChain) error
if
err
:=
blockchain
.
Validator
()
.
ValidateHeader
(
header
,
blockchain
.
GetHeader
(
header
.
ParentHash
),
false
);
err
!=
nil
{
return
err
}
// Manually insert the header into the database, but don't reorgani
z
e (allows subsequent testing)
// Manually insert the header into the database, but don't reorgani
s
e (allows subsequent testing)
blockchain
.
mu
.
Lock
()
WriteTd
(
blockchain
.
chainDb
,
header
.
Hash
(),
new
(
big
.
Int
)
.
Add
(
header
.
Difficulty
,
blockchain
.
GetTd
(
header
.
ParentHash
)))
WriteHeader
(
blockchain
.
chainDb
,
header
)
...
...
@@ -491,7 +491,7 @@ func chm(genesis *types.Block, db ethdb.Database) *BlockChain {
return
bc
}
// Tests that reorgani
z
ing a long difficult chain after a short easy one
// Tests that reorgani
s
ing a long difficult chain after a short easy one
// overwrites the canonical numbers and links in the database.
func
TestReorgLongHeaders
(
t
*
testing
.
T
)
{
testReorgLong
(
t
,
false
)
}
func
TestReorgLongBlocks
(
t
*
testing
.
T
)
{
testReorgLong
(
t
,
true
)
}
...
...
@@ -500,7 +500,7 @@ func testReorgLong(t *testing.T, full bool) {
testReorg
(
t
,
[]
int
{
1
,
2
,
4
},
[]
int
{
1
,
2
,
3
,
4
},
10
,
full
)
}
// Tests that reorgani
z
ing a short difficult chain after a long easy one
// Tests that reorgani
s
ing a short difficult chain after a long easy one
// overwrites the canonical numbers and links in the database.
func
TestReorgShortHeaders
(
t
*
testing
.
T
)
{
testReorgShort
(
t
,
false
)
}
func
TestReorgShortBlocks
(
t
*
testing
.
T
)
{
testReorgShort
(
t
,
true
)
}
...
...
@@ -858,7 +858,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) {
assert
(
t
,
"light"
,
light
,
height
/
2
,
0
,
0
)
}
// Tests that chain reorgani
z
ations handle transaction removals and reinsertions.
// Tests that chain reorgani
s
ations handle transaction removals and reinsertions.
func
TestChainTxReorgs
(
t
*
testing
.
T
)
{
params
.
MinGasLimit
=
big
.
NewInt
(
125000
)
// Minimum the gas limit may ever be.
params
.
GenesisGasLimit
=
big
.
NewInt
(
3141592
)
// Gas limit of the Genesis block.
...
...
core/tx_pool_test.go
浏览文件 @
434e4b31
...
...
@@ -366,7 +366,7 @@ func TestTransactionPostponing(t *testing.T) {
if
len
(
pool
.
queue
[
account
])
!=
0
{
t
.
Errorf
(
"queued transaction mismatch: have %d, want %d"
,
len
(
pool
.
queue
),
0
)
}
// Reduce the balance of the account, and check that transactions are reorgani
z
ed
// Reduce the balance of the account, and check that transactions are reorgani
s
ed
state
.
AddBalance
(
account
,
big
.
NewInt
(
-
750
))
pool
.
resetState
()
...
...
eth/downloader/downloader.go
浏览文件 @
434e4b31
...
...
@@ -534,7 +534,7 @@ func (d *Downloader) fetchHeight61(p *peer) (uint64, error) {
// findAncestor61 tries to locate the common ancestor block of the local chain and
// a remote peers blockchain. In the general case when our node was in sync and
// on the correct chain, checking the top N blocks should already get us a match.
// In the rare scenario when we ended up on a long reorgani
z
ation (i.e. none of
// In the rare scenario when we ended up on a long reorgani
s
ation (i.e. none of
// the head blocks match), we do a binary search to find the common ancestor.
func
(
d
*
Downloader
)
findAncestor61
(
p
*
peer
)
(
uint64
,
error
)
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"%v: looking for common ancestor"
,
p
)
...
...
@@ -960,7 +960,7 @@ func (d *Downloader) fetchHeight(p *peer) (uint64, error) {
// findAncestor tries to locate the common ancestor link of the local chain and
// a remote peers blockchain. In the general case when our node was in sync and
// on the correct chain, checking the top N links should already get us a match.
// In the rare scenario when we ended up on a long reorgani
z
ation (i.e. none of
// In the rare scenario when we ended up on a long reorgani
s
ation (i.e. none of
// the head links match), we do a binary search to find the common ancestor.
func
(
d
*
Downloader
)
findAncestor
(
p
*
peer
)
(
uint64
,
error
)
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"%v: looking for common ancestor"
,
p
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录