Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
01813884
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,发现更多精彩内容 >>
提交
01813884
编写于
7月 09, 2018
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add abi serializer max time to calls to abi serializer
上级
8843f5fa
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
14 addition
and
10 deletion
+14
-10
plugins/mongo_db_plugin/mongo_db_plugin.cpp
plugins/mongo_db_plugin/mongo_db_plugin.cpp
+14
-10
未找到文件。
plugins/mongo_db_plugin/mongo_db_plugin.cpp
浏览文件 @
01813884
...
@@ -101,6 +101,7 @@ public:
...
@@ -101,6 +101,7 @@ public:
boost
::
atomic
<
bool
>
done
{
false
};
boost
::
atomic
<
bool
>
done
{
false
};
boost
::
atomic
<
bool
>
startup
{
true
};
boost
::
atomic
<
bool
>
startup
{
true
};
fc
::
optional
<
chain
::
chain_id_type
>
chain_id
;
fc
::
optional
<
chain
::
chain_id_type
>
chain_id
;
fc
::
microseconds
abi_serializer_max_time
;
static
const
account_name
newaccount
;
static
const
account_name
newaccount
;
static
const
account_name
setabi
;
static
const
account_name
setabi
;
...
@@ -309,7 +310,7 @@ namespace {
...
@@ -309,7 +310,7 @@ namespace {
return
blocks
.
find_one
(
make_document
(
kvp
(
"block_id"
,
id
)));
return
blocks
.
find_one
(
make_document
(
kvp
(
"block_id"
,
id
)));
}
}
optional
<
abi_serializer
>
get_abi_serializer
(
account_name
n
,
mongocxx
::
collection
&
accounts
)
{
optional
<
abi_serializer
>
get_abi_serializer
(
account_name
n
,
mongocxx
::
collection
&
accounts
,
const
fc
::
microseconds
&
abi_serializer_max_time
)
{
using
bsoncxx
::
builder
::
basic
::
kvp
;
using
bsoncxx
::
builder
::
basic
::
kvp
;
using
bsoncxx
::
builder
::
basic
::
make_document
;
using
bsoncxx
::
builder
::
basic
::
make_document
;
if
(
n
.
good
())
{
if
(
n
.
good
())
{
...
@@ -325,7 +326,7 @@ namespace {
...
@@ -325,7 +326,7 @@ namespace {
ilog
(
"Unable to convert account abi to abi_def for ${n}"
,
(
"n"
,
n
));
ilog
(
"Unable to convert account abi to abi_def for ${n}"
,
(
"n"
,
n
));
return
optional
<
abi_serializer
>
();
return
optional
<
abi_serializer
>
();
}
}
return
abi_serializer
(
abi
);
return
abi_serializer
(
abi
,
abi_serializer_max_time
);
}
}
}
}
}
FC_CAPTURE_AND_LOG
((
n
))
}
FC_CAPTURE_AND_LOG
((
n
))
...
@@ -334,9 +335,11 @@ namespace {
...
@@ -334,9 +335,11 @@ namespace {
}
}
template
<
typename
T
>
template
<
typename
T
>
fc
::
variant
to_variant_with_abi
(
const
T
&
obj
,
mongocxx
::
collection
&
accounts
)
{
fc
::
variant
to_variant_with_abi
(
const
T
&
obj
,
mongocxx
::
collection
&
accounts
,
const
fc
::
microseconds
&
abi_serializer_max_time
)
{
fc
::
variant
pretty_output
;
fc
::
variant
pretty_output
;
abi_serializer
::
to_variant
(
obj
,
pretty_output
,
[
&
](
account_name
n
)
{
return
get_abi_serializer
(
n
,
accounts
);
}
);
abi_serializer
::
to_variant
(
obj
,
pretty_output
,
[
&
](
account_name
n
)
{
return
get_abi_serializer
(
n
,
accounts
,
abi_serializer_max_time
);
},
abi_serializer_max_time
);
return
pretty_output
;
return
pretty_output
;
}
}
...
@@ -442,7 +445,7 @@ void handle_mongo_exception( const std::string& desc, int line_num ) {
...
@@ -442,7 +445,7 @@ void handle_mongo_exception( const std::string& desc, int line_num ) {
}
}
}
}
void
add_data
(
bsoncxx
::
builder
::
basic
::
document
&
act_doc
,
mongocxx
::
collection
&
accounts
,
const
chain
::
action
&
act
)
{
void
add_data
(
bsoncxx
::
builder
::
basic
::
document
&
act_doc
,
mongocxx
::
collection
&
accounts
,
const
chain
::
action
&
act
,
const
fc
::
microseconds
&
abi_serializer_max_time
)
{
using
bsoncxx
::
builder
::
basic
::
kvp
;
using
bsoncxx
::
builder
::
basic
::
kvp
;
using
bsoncxx
::
builder
::
basic
::
make_document
;
using
bsoncxx
::
builder
::
basic
::
make_document
;
try
{
try
{
...
@@ -478,8 +481,8 @@ void add_data( bsoncxx::builder::basic::document& act_doc, mongocxx::collection&
...
@@ -478,8 +481,8 @@ void add_data( bsoncxx::builder::basic::document& act_doc, mongocxx::collection&
string
json
;
string
json
;
try
{
try
{
abi_serializer
abis
;
abi_serializer
abis
;
abis
.
set_abi
(
abi
);
abis
.
set_abi
(
abi
,
abi_serializer_max_time
);
auto
v
=
abis
.
binary_to_variant
(
abis
.
get_action_type
(
act
.
name
),
act
.
data
);
auto
v
=
abis
.
binary_to_variant
(
abis
.
get_action_type
(
act
.
name
),
act
.
data
,
abi_serializer_max_time
);
json
=
fc
::
json
::
to_string
(
v
);
json
=
fc
::
json
::
to_string
(
v
);
const
auto
&
value
=
bsoncxx
::
from_json
(
json
);
const
auto
&
value
=
bsoncxx
::
from_json
(
json
);
...
@@ -613,7 +616,7 @@ void mongo_db_plugin_impl::_process_accepted_transaction( const chain::transacti
...
@@ -613,7 +616,7 @@ void mongo_db_plugin_impl::_process_accepted_transaction( const chain::transacti
ilog
(
"Unable to update account for ${s}::${n}"
,
(
"s"
,
act
.
account
)(
"n"
,
act
.
name
));
ilog
(
"Unable to update account for ${s}::${n}"
,
(
"s"
,
act
.
account
)(
"n"
,
act
.
name
));
}
}
if
(
start_block_reached
)
{
if
(
start_block_reached
)
{
add_data
(
act_doc
,
accounts
,
act
);
add_data
(
act_doc
,
accounts
,
act
,
abi_serializer_max_time
);
act_array
.
append
(
act_doc
);
act_array
.
append
(
act_doc
);
mongocxx
::
model
::
insert_one
insert_op
{
act_doc
.
view
()};
mongocxx
::
model
::
insert_one
insert_op
{
act_doc
.
view
()};
bulk_actions
.
append
(
insert_op
);
bulk_actions
.
append
(
insert_op
);
...
@@ -768,7 +771,7 @@ void mongo_db_plugin_impl::_process_applied_transaction( const chain::transactio
...
@@ -768,7 +771,7 @@ void mongo_db_plugin_impl::_process_applied_transaction( const chain::transactio
auto
now
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
auto
now
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
microseconds
{
fc
::
time_point
::
now
().
time_since_epoch
().
count
()});
std
::
chrono
::
microseconds
{
fc
::
time_point
::
now
().
time_since_epoch
().
count
()});
auto
v
=
to_variant_with_abi
(
*
t
,
accounts
);
auto
v
=
to_variant_with_abi
(
*
t
,
accounts
,
abi_serializer_max_time
);
string
json
=
fc
::
json
::
to_string
(
v
);
string
json
=
fc
::
json
::
to_string
(
v
);
try
{
try
{
const
auto
&
value
=
bsoncxx
::
from_json
(
json
);
const
auto
&
value
=
bsoncxx
::
from_json
(
json
);
...
@@ -848,7 +851,7 @@ void mongo_db_plugin_impl::_process_accepted_block( const chain::block_state_ptr
...
@@ -848,7 +851,7 @@ void mongo_db_plugin_impl::_process_accepted_block( const chain::block_state_ptr
kvp
(
"block_id"
,
block_id_str
),
kvp
(
"block_id"
,
block_id_str
),
kvp
(
"irreversible"
,
b_bool
{
false
}
));
kvp
(
"irreversible"
,
b_bool
{
false
}
));
auto
v
=
to_variant_with_abi
(
*
bs
->
block
,
accounts
);
auto
v
=
to_variant_with_abi
(
*
bs
->
block
,
accounts
,
abi_serializer_max_time
);
json
=
fc
::
json
::
to_string
(
v
);
json
=
fc
::
json
::
to_string
(
v
);
try
{
try
{
const
auto
&
value
=
bsoncxx
::
from_json
(
json
);
const
auto
&
value
=
bsoncxx
::
from_json
(
json
);
...
@@ -1094,6 +1097,7 @@ void mongo_db_plugin::plugin_initialize(const variables_map& options)
...
@@ -1094,6 +1097,7 @@ void mongo_db_plugin::plugin_initialize(const variables_map& options)
if
(
options
.
count
(
"abi-serializer-max-time-ms"
)
==
0
)
{
if
(
options
.
count
(
"abi-serializer-max-time-ms"
)
==
0
)
{
FC_ASSERT
(
false
,
"--abi-serializer-max-time-ms required as default value not appropriate for parsing full blocks"
);
FC_ASSERT
(
false
,
"--abi-serializer-max-time-ms required as default value not appropriate for parsing full blocks"
);
my
->
abi_serializer_max_time
=
app
().
get_plugin
<
chain_plugin
>
().
get_abi_serializer_max_time
();
}
}
if
(
options
.
count
(
"mongodb-queue-size"
))
{
if
(
options
.
count
(
"mongodb-queue-size"
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录