Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
4089d763
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,发现更多精彩内容 >>
提交
4089d763
编写于
5月 03, 2018
作者:
B
Bart Wyatt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
exception safety
上级
8ea56d86
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
17 deletion
+56
-17
libraries/fc/include/fc/exception/exception.hpp
libraries/fc/include/fc/exception/exception.hpp
+17
-0
plugins/chain_plugin/chain_plugin.cpp
plugins/chain_plugin/chain_plugin.cpp
+3
-1
plugins/producer_plugin/producer_plugin.cpp
plugins/producer_plugin/producer_plugin.cpp
+36
-16
未找到文件。
libraries/fc/include/fc/exception/exception.hpp
浏览文件 @
4089d763
...
...
@@ -444,6 +444,23 @@ namespace fc
wdump( __VA_ARGS__ ); \
}
#define FC_LOG_AND_DROP( ... ) \
catch( fc::exception& er ) { \
wlog( "${details}", ("details",er.to_detail_string()) ); \
} catch( const std::exception& e ) { \
fc::exception fce( \
FC_LOG_MESSAGE( warn, "rethrow ${what}: ",FC_FORMAT_ARG_PARAMS( __VA_ARGS__ )("what",e.what()) ), \
fc::std_exception_code,\
BOOST_CORE_TYPEID(e).name(), \
e.what() ) ; \
wlog( "${details}", ("details",fce.to_detail_string()) ); \
} catch( ... ) { \
fc::unhandled_exception e( \
FC_LOG_MESSAGE( warn, "rethrow", FC_FORMAT_ARG_PARAMS( __VA_ARGS__) ), \
std::current_exception() ); \
wlog( "${details}", ("details",e.to_detail_string()) ); \
}
/**
* @def FC_RETHROW_EXCEPTIONS(LOG_LEVEL,FORMAT,...)
...
...
plugins/chain_plugin/chain_plugin.cpp
浏览文件 @
4089d763
...
...
@@ -257,7 +257,9 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
});
my
->
incoming_transaction_subscription
=
app
().
get_channel
<
channels
::
incoming_transaction
>
().
subscribe
([
this
](
const
packed_transaction_ptr
&
ptrx
){
my
->
chain
->
push_transaction
(
std
::
make_shared
<
transaction_metadata
>
(
*
ptrx
),
get_transaction_deadline
());
try
{
my
->
chain
->
push_transaction
(
std
::
make_shared
<
transaction_metadata
>
(
*
ptrx
),
get_transaction_deadline
());
}
FC_LOG_AND_DROP
();
});
}
...
...
plugins/producer_plugin/producer_plugin.cpp
浏览文件 @
4089d763
...
...
@@ -96,8 +96,10 @@ class producer_plugin_impl {
// abort the pending block
chain
.
abort_block
();
// push the new block
chain
.
push_block
(
block
);
try
{
// push the new block
chain
.
push_block
(
block
);
}
FC_LOG_AND_DROP
();
// restart our production loop
schedule_production_loop
();
...
...
@@ -234,7 +236,7 @@ void producer_plugin::plugin_startup()
my
->
schedule_production_loop
();
}
else
elog
(
"No producers configured! Please add producer IDs and private keys to configuration."
);
ilog
(
"producer plugin: plugin_startup() end"
);
ilog
(
"producer plugin: plugin_startup() end"
);
}
FC_CAPTURE_AND_RETHROW
()
}
void
producer_plugin
::
plugin_shutdown
()
{
...
...
@@ -260,23 +262,41 @@ void producer_plugin_impl::schedule_production_loop() {
}
fc
::
time_point
block_time
=
now
+
fc
::
microseconds
(
time_to_next_block_time
);
static
const
boost
::
posix_time
::
ptime
epoch
(
boost
::
gregorian
::
date
(
1970
,
1
,
1
));
_timer
.
expires_at
(
epoch
+
boost
::
posix_time
::
microseconds
(
block_time
.
time_since_epoch
().
count
()));
chain
::
controller
&
chain
=
app
().
get_plugin
<
chain_plugin
>
().
chain
();
chain
.
abort_block
();
chain
.
start_block
(
block_time
);
try
{
chain
.
abort_block
();
chain
.
start_block
(
block_time
);
}
FC_LOG_AND_DROP
();
// TODO: BIG BAD WARNING, THIS WILL HAPPILY BLOW PAST DEADLINES BUT CONTROLLER IS NOT YET SAFE FOR DEADLINE USAGE
while
(
chain
.
push_next_unapplied_transaction
(
fc
::
time_point
::
maximum
()
)
);
while
(
chain
.
push_next_scheduled_transaction
(
fc
::
time_point
::
maximum
()
)
);
if
(
chain
.
pending_block_state
())
{
// TODO: BIG BAD WARNING, THIS WILL HAPPILY BLOW PAST DEADLINES BUT CONTROLLER IS NOT YET SAFE FOR DEADLINE USAGE
try
{
while
(
chain
.
push_next_unapplied_transaction
(
fc
::
time_point
::
maximum
()));
}
FC_LOG_AND_DROP
();
static
const
boost
::
posix_time
::
ptime
epoch
(
boost
::
gregorian
::
date
(
1970
,
1
,
1
));
_timer
.
expires_at
(
epoch
+
boost
::
posix_time
::
microseconds
(
block_time
.
time_since_epoch
().
count
()));
//_timer.async_wait(boost::bind(&producer_plugin_impl::block_production_loop, this));
_timer
.
async_wait
(
[
&
](
const
boost
::
system
::
error_code
&
ec
){
if
(
ec
!=
boost
::
asio
::
error
::
operation_aborted
)
{
block_production_loop
();
}
});
try
{
while
(
chain
.
push_next_scheduled_transaction
(
fc
::
time_point
::
maximum
()));
}
FC_LOG_AND_DROP
();
//_timer.async_wait(boost::bind(&producer_plugin_impl::block_production_loop, this));
_timer
.
async_wait
([
&
](
const
boost
::
system
::
error_code
&
ec
)
{
if
(
ec
!=
boost
::
asio
::
error
::
operation_aborted
)
{
block_production_loop
();
}
});
}
else
{
elog
(
"Failed to start a pending block, will try again later"
);
// we failed to start a block, so try again later?
_timer
.
async_wait
([
&
](
const
boost
::
system
::
error_code
&
ec
)
{
if
(
ec
!=
boost
::
asio
::
error
::
operation_aborted
)
{
schedule_production_loop
();
}
});
}
}
block_production_condition
::
block_production_condition_enum
producer_plugin_impl
::
block_production_loop
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录