Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
a339b5d6
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a339b5d6
编写于
5月 03, 2018
作者:
W
wanderingbort
提交者:
GitHub
5月 03, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2714 from wanderingbort/feature/explicitly-remove-implicit-calls
explicitly remove implicit calls
上级
78615689
c045881d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
4 deletion
+14
-4
libraries/chain/controller.cpp
libraries/chain/controller.cpp
+6
-4
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+2
-0
unittests/forked_tests.cpp
unittests/forked_tests.cpp
+6
-0
未找到文件。
libraries/chain/controller.cpp
浏览文件 @
a339b5d6
...
@@ -710,8 +710,8 @@ struct controller_impl {
...
@@ -710,8 +710,8 @@ struct controller_impl {
void
push_block
(
const
signed_block_ptr
&
b
)
{
void
push_block
(
const
signed_block_ptr
&
b
)
{
FC_ASSERT
(
!
pending
,
"it is not valid to push a block when there is a pending block"
);
try
{
try
{
if
(
pending
)
abort_block
();
FC_ASSERT
(
b
);
FC_ASSERT
(
b
);
auto
new_header_state
=
fork_db
.
add
(
b
);
auto
new_header_state
=
fork_db
.
add
(
b
);
emit
(
self
.
accepted_block_header
,
new_header_state
);
emit
(
self
.
accepted_block_header
,
new_header_state
);
...
@@ -720,6 +720,7 @@ struct controller_impl {
...
@@ -720,6 +720,7 @@ struct controller_impl {
}
}
void
push_confirmation
(
const
header_confirmation
&
c
)
{
void
push_confirmation
(
const
header_confirmation
&
c
)
{
FC_ASSERT
(
!
pending
,
"it is not valid to push a confirmation when there is a pending block"
);
fork_db
.
add
(
c
);
fork_db
.
add
(
c
);
emit
(
self
.
accepted_confirmation
,
c
);
emit
(
self
.
accepted_confirmation
,
c
);
maybe_switch_forks
();
maybe_switch_forks
();
...
@@ -730,7 +731,6 @@ struct controller_impl {
...
@@ -730,7 +731,6 @@ struct controller_impl {
if
(
new_head
->
header
.
previous
==
head
->
id
)
{
if
(
new_head
->
header
.
previous
==
head
->
id
)
{
try
{
try
{
abort_block
();
apply_block
(
new_head
->
block
);
apply_block
(
new_head
->
block
);
fork_db
.
mark_in_current_chain
(
new_head
,
true
);
fork_db
.
mark_in_current_chain
(
new_head
,
true
);
fork_db
.
set_validity
(
new_head
,
true
);
fork_db
.
set_validity
(
new_head
,
true
);
...
@@ -822,8 +822,10 @@ struct controller_impl {
...
@@ -822,8 +822,10 @@ struct controller_impl {
void
finalize_block
()
void
finalize_block
()
{
try
{
{
if
(
!
pending
)
self
.
start_block
();
FC_ASSERT
(
pending
,
"it is not valid to finalize when there is no pending block"
);
try
{
/*
/*
ilog( "finalize block ${n} (${id}) at ${t} by ${p} (${signing_key}); schedule_version: ${v} lib: ${lib} #dtrxs: ${ndtrxs} ${np}",
ilog( "finalize block ${n} (${id}) at ${t} by ${p} (${signing_key}); schedule_version: ${v} lib: ${lib} #dtrxs: ${ndtrxs} ${np}",
...
...
libraries/testing/tester.cpp
浏览文件 @
a339b5d6
...
@@ -83,6 +83,7 @@ namespace eosio { namespace testing {
...
@@ -83,6 +83,7 @@ namespace eosio { namespace testing {
}
}
signed_block_ptr
base_tester
::
push_block
(
signed_block_ptr
b
)
{
signed_block_ptr
base_tester
::
push_block
(
signed_block_ptr
b
)
{
control
->
abort_block
();
control
->
push_block
(
b
);
control
->
push_block
(
b
);
return
b
;
return
b
;
}
}
...
@@ -650,6 +651,7 @@ namespace eosio { namespace testing {
...
@@ -650,6 +651,7 @@ namespace eosio { namespace testing {
for
(
int
i
=
1
;
i
<=
a
.
control
->
head_block_num
();
++
i
)
{
for
(
int
i
=
1
;
i
<=
a
.
control
->
head_block_num
();
++
i
)
{
auto
block
=
a
.
control
->
fetch_block_by_number
(
i
);
auto
block
=
a
.
control
->
fetch_block_by_number
(
i
);
if
(
block
)
{
//&& !b.control->is_known_block(block->id()) ) {
if
(
block
)
{
//&& !b.control->is_known_block(block->id()) ) {
b
.
control
->
abort_block
();
b
.
control
->
push_block
(
block
);
//, eosio::chain::validation_steps::created_block);
b
.
control
->
push_block
(
block
);
//, eosio::chain::validation_steps::created_block);
}
}
}
}
...
...
unittests/forked_tests.cpp
浏览文件 @
a339b5d6
...
@@ -82,6 +82,7 @@ BOOST_AUTO_TEST_CASE( forking ) try {
...
@@ -82,6 +82,7 @@ BOOST_AUTO_TEST_CASE( forking ) try {
wlog
(
"push c1 blocks to c2"
);
wlog
(
"push c1 blocks to c2"
);
while
(
c2
.
control
->
head_block_num
()
<
c
.
control
->
head_block_num
()
)
{
while
(
c2
.
control
->
head_block_num
()
<
c
.
control
->
head_block_num
()
)
{
auto
fb
=
c
.
control
->
fetch_block_by_number
(
c2
.
control
->
head_block_num
()
+
1
);
auto
fb
=
c
.
control
->
fetch_block_by_number
(
c2
.
control
->
head_block_num
()
+
1
);
c2
.
control
->
abort_block
();
c2
.
control
->
push_block
(
fb
);
c2
.
control
->
push_block
(
fb
);
}
}
wlog
(
"end push c1 blocks to c2"
);
wlog
(
"end push c1 blocks to c2"
);
...
@@ -107,6 +108,7 @@ BOOST_AUTO_TEST_CASE( forking ) try {
...
@@ -107,6 +108,7 @@ BOOST_AUTO_TEST_CASE( forking ) try {
wlog
(
"push c1 blocks to c2"
);
wlog
(
"push c1 blocks to c2"
);
while
(
c2
.
control
->
head_block_num
()
<
c
.
control
->
head_block_num
()
)
{
while
(
c2
.
control
->
head_block_num
()
<
c
.
control
->
head_block_num
()
)
{
auto
fb
=
c
.
control
->
fetch_block_by_number
(
c2
.
control
->
head_block_num
()
+
1
);
auto
fb
=
c
.
control
->
fetch_block_by_number
(
c2
.
control
->
head_block_num
()
+
1
);
c2
.
control
->
abort_block
();
c2
.
control
->
push_block
(
fb
);
c2
.
control
->
push_block
(
fb
);
}
}
wlog
(
"end push c1 blocks to c2"
);
wlog
(
"end push c1 blocks to c2"
);
...
@@ -134,6 +136,7 @@ BOOST_AUTO_TEST_CASE( forking ) try {
...
@@ -134,6 +136,7 @@ BOOST_AUTO_TEST_CASE( forking ) try {
wlog
(
"push c2 blocks to c1"
);
wlog
(
"push c2 blocks to c1"
);
for
(
uint32_t
start
=
fork_block_num
+
1
,
end
=
c2
.
control
->
head_block_num
();
start
<=
end
;
++
start
)
{
for
(
uint32_t
start
=
fork_block_num
+
1
,
end
=
c2
.
control
->
head_block_num
();
start
<=
end
;
++
start
)
{
auto
fb
=
c2
.
control
->
fetch_block_by_number
(
start
);
auto
fb
=
c2
.
control
->
fetch_block_by_number
(
start
);
c
.
control
->
abort_block
();
c
.
control
->
push_block
(
fb
);
c
.
control
->
push_block
(
fb
);
}
}
wlog
(
"end push c2 blocks to c1"
);
wlog
(
"end push c2 blocks to c1"
);
...
@@ -153,6 +156,7 @@ BOOST_AUTO_TEST_CASE( forking ) try {
...
@@ -153,6 +156,7 @@ BOOST_AUTO_TEST_CASE( forking ) try {
wlog
(
"push c1 blocks to c2"
);
wlog
(
"push c1 blocks to c2"
);
while
(
c2
.
control
->
head_block_num
()
<
c
.
control
->
head_block_num
()
)
{
while
(
c2
.
control
->
head_block_num
()
<
c
.
control
->
head_block_num
()
)
{
auto
fb
=
c
.
control
->
fetch_block_by_number
(
c2
.
control
->
head_block_num
()
+
1
);
auto
fb
=
c
.
control
->
fetch_block_by_number
(
c2
.
control
->
head_block_num
()
+
1
);
c2
.
control
->
abort_block
();
c2
.
control
->
push_block
(
fb
);
c2
.
control
->
push_block
(
fb
);
}
}
wlog
(
"end push c1 blocks to c2"
);
wlog
(
"end push c1 blocks to c2"
);
...
@@ -180,12 +184,14 @@ BOOST_AUTO_TEST_CASE( forking ) try {
...
@@ -180,12 +184,14 @@ BOOST_AUTO_TEST_CASE( forking ) try {
wlog
(
"push c2 blocks (except for the last block by dan) to c1"
);
wlog
(
"push c2 blocks (except for the last block by dan) to c1"
);
for
(
uint32_t
start
=
fork_block_num
+
1
,
end
=
c2
.
control
->
head_block_num
()
-
1
;
start
<=
end
;
++
start
)
{
for
(
uint32_t
start
=
fork_block_num
+
1
,
end
=
c2
.
control
->
head_block_num
()
-
1
;
start
<=
end
;
++
start
)
{
auto
fb
=
c2
.
control
->
fetch_block_by_number
(
start
);
auto
fb
=
c2
.
control
->
fetch_block_by_number
(
start
);
c
.
control
->
abort_block
();
c
.
control
->
push_block
(
fb
);
c
.
control
->
push_block
(
fb
);
}
}
wlog
(
"end push c2 blocks to c1"
);
wlog
(
"end push c2 blocks to c1"
);
wlog
(
"now push dan's block to c1 but first corrupt it so it is a bad block"
);
wlog
(
"now push dan's block to c1 but first corrupt it so it is a bad block"
);
auto
bad_block
=
*
b
;
auto
bad_block
=
*
b
;
bad_block
.
transaction_mroot
=
bad_block
.
previous
;
bad_block
.
transaction_mroot
=
bad_block
.
previous
;
c
.
control
->
abort_block
();
BOOST_REQUIRE_EXCEPTION
(
c
.
control
->
push_block
(
std
::
make_shared
<
signed_block
>
(
bad_block
)
),
fc
::
exception
,
BOOST_REQUIRE_EXCEPTION
(
c
.
control
->
push_block
(
std
::
make_shared
<
signed_block
>
(
bad_block
)
),
fc
::
exception
,
[]
(
const
fc
::
exception
&
ex
)
->
bool
{
[]
(
const
fc
::
exception
&
ex
)
->
bool
{
return
ex
.
to_detail_string
().
find
(
"block not signed by expected key"
)
!=
std
::
string
::
npos
;
return
ex
.
to_detail_string
().
find
(
"block not signed by expected key"
)
!=
std
::
string
::
npos
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录