Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
32d55ab5
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,发现更多精彩内容 >>
提交
32d55ab5
编写于
4月 28, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Catch exceptions thrown from signals
- this change prevents plugins from causing a node to reject valid blocks.
上级
93b9ea2f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
10 deletion
+31
-10
libraries/chain/controller.cpp
libraries/chain/controller.cpp
+27
-10
libraries/chain/include/eosio/chain/controller.hpp
libraries/chain/include/eosio/chain/controller.hpp
+4
-0
未找到文件。
libraries/chain/controller.cpp
浏览文件 @
32d55ab5
...
...
@@ -112,6 +112,23 @@ struct controller_impl {
}
/**
* Plugins / observers listening to signals emited (such as accepted_transaction) might trigger
* errors and throw exceptions. Unless those exceptions are caught it could impact consensus and/or
* cause a node to fork.
*
* TODO: define special exceptions that can be thrown to reject transactions or blocks
*/
template
<
typename
Signal
,
typename
Arg
>
void
emit
(
const
Signal
&
s
,
Arg
&&
a
)
{
try
{
s
(
std
::
forward
<
Arg
>
(
a
));
}
catch
(
...
)
{
elog
(
"signal handler threw exception"
);
}
}
void
on_irreversible
(
const
block_state_ptr
&
s
)
{
if
(
!
blog
.
head
()
)
blog
.
read_head
();
...
...
@@ -130,7 +147,7 @@ struct controller_impl {
FC_ASSERT
(
s
->
id
==
log_head
->
id
(),
""
,
(
"s->id"
,
s
->
id
)(
"hid"
,
log_head
->
id
())
);
}
}
self
.
irreversible_block
(
s
);
emit
(
self
.
irreversible_block
,
s
);
db
.
commit
(
s
->
block_num
);
}
...
...
@@ -334,7 +351,7 @@ struct controller_impl {
}
//ilog((fc::json::to_pretty_string(*pending->_pending_block_state->block)));
self
.
accepted_block
(
pending
->
_pending_block_state
);
emit
(
self
.
accepted_block
,
pending
->
_pending_block_state
);
pending
->
push
();
pending
.
reset
();
...
...
@@ -356,7 +373,7 @@ struct controller_impl {
trx_context
.
is_input
=
false
;
trx_context
.
exec
();
self
.
applied_transaction
(
trx_context
.
trace
);
emit
(
self
.
applied_transaction
,
trx_context
.
trace
);
trx_context
.
squash
();
return
move
(
trx_context
.
trace
);
...
...
@@ -418,7 +435,7 @@ struct controller_impl {
db
.
remove
(
gto
);
self
.
applied_transaction
(
trx_context
.
trace
);
emit
(
self
.
applied_transaction
,
trx_context
.
trace
);
trx_context
.
squash
();
return
;
...
...
@@ -431,7 +448,7 @@ struct controller_impl {
try
{
auto
trace
=
apply_onerror
(
gto
,
deadline
,
apply_cpu_usage
);
trace
->
soft_except
=
soft_except
;
self
.
applied_transaction
(
trace
);
emit
(
self
.
applied_transaction
,
trace
);
}
catch
(
const
fc
::
exception
&
e
)
{
hard_except
=
e
;
trace
->
hard_except_ptr
=
std
::
current_exception
();
...
...
@@ -454,7 +471,7 @@ struct controller_impl {
db
.
remove
(
gto
);
self
.
applied_transaction
(
trace
);
emit
(
self
.
applied_transaction
,
trace
);
}
/// push_scheduled_transaction
...
...
@@ -542,8 +559,8 @@ struct controller_impl {
if
(
!
implicit
)
pending
->
_pending_block_state
->
trxs
.
emplace_back
(
trx
);
self
.
accepted_transaction
(
trx
);
self
.
applied_transaction
(
trace
);
emit
(
self
.
accepted_transaction
,
trx
);
emit
(
self
.
applied_transaction
,
trace
);
trx_context
.
squash
();
return
;
}
catch
(
const
fc
::
exception
&
e
)
{
...
...
@@ -643,14 +660,14 @@ struct controller_impl {
try
{
FC_ASSERT
(
b
);
auto
new_header_state
=
fork_db
.
add
(
b
);
self
.
accepted_block_header
(
new_header_state
);
emit
(
self
.
accepted_block_header
,
new_header_state
);
maybe_switch_forks
();
}
FC_LOG_AND_RETHROW
()
}
void
push_confirmation
(
const
header_confirmation
&
c
)
{
fork_db
.
add
(
c
);
self
.
accepted_confirmation
(
c
);
emit
(
self
.
accepted_confirmation
,
c
);
maybe_switch_forks
();
}
...
...
libraries/chain/include/eosio/chain/controller.hpp
浏览文件 @
32d55ab5
...
...
@@ -151,6 +151,9 @@ namespace eosio { namespace chain {
bool
set_proposed_producers
(
vector
<
producer_key
>
producers
);
signal
<
void
(
const
block_state_ptr
&
)
>
accepted_block_header
;
signal
<
void
(
const
block_state_ptr
&
)
>
accepted_block
;
signal
<
void
(
const
block_state_ptr
&
)
>
irreversible_block
;
...
...
@@ -188,6 +191,7 @@ namespace eosio { namespace chain {
}
private:
std
::
unique_ptr
<
controller_impl
>
my
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录