Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
46387eba
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,发现更多精彩内容 >>
提交
46387eba
编写于
10月 13, 2017
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix for resync startup #172
上级
5a7553b4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
43 deletion
+55
-43
plugins/db_plugin/db_plugin.cpp
plugins/db_plugin/db_plugin.cpp
+55
-43
未找到文件。
plugins/db_plugin/db_plugin.cpp
浏览文件 @
46387eba
...
...
@@ -110,43 +110,59 @@ const std::string db_plugin_impl::accounts_col = "Accounts";
void
db_plugin_impl
::
applied_irreversible_block
(
const
signed_block
&
block
)
{
if
(
startup
)
{
// on startup we don't want to queue, instead push back on caller
process_irreversible_block
(
block
);
}
else
{
boost
::
mutex
::
scoped_lock
lock
(
mtx
);
queue
.
push
(
block
);
lock
.
unlock
();
condtion
.
notify_one
();
try
{
if
(
startup
)
{
// on startup we don't want to queue, instead push back on caller
process_irreversible_block
(
block
);
}
else
{
boost
::
mutex
::
scoped_lock
lock
(
mtx
);
queue
.
push
(
block
);
lock
.
unlock
();
condtion
.
notify_one
();
}
}
catch
(
fc
::
exception
&
e
)
{
elog
(
"FC Exception while applied_irreversible_block ${e}"
,
(
"e"
,
e
.
to_string
()));
}
catch
(
std
::
exception
&
e
)
{
elog
(
"STD Exception while applied_irreversible_block ${e}"
,
(
"e"
,
e
.
what
()));
}
catch
(...)
{
elog
(
"Unknown exception while applied_irreversible_block"
);
}
}
void
db_plugin_impl
::
consum_blocks
()
{
signed_block
block
;
size_t
size
=
0
;
while
(
true
)
{
boost
::
mutex
::
scoped_lock
lock
(
mtx
);
while
(
queue
.
empty
()
&&
!
done
)
{
condtion
.
wait
(
lock
);
}
size
=
queue
.
size
();
if
(
size
>
0
)
{
block
=
queue
.
front
();
queue
.
pop
();
lock
.
unlock
();
// warn if queue size greater than 75%
if
(
size
>
(
queue_size
*
0.75
))
{
wlog
(
"queue size: ${q}"
,
(
"q"
,
size
+
1
));
try
{
signed_block
block
;
size_t
size
=
0
;
while
(
true
)
{
boost
::
mutex
::
scoped_lock
lock
(
mtx
);
while
(
queue
.
empty
()
&&
!
done
)
{
condtion
.
wait
(
lock
);
}
size
=
queue
.
size
();
if
(
size
>
0
)
{
block
=
queue
.
front
();
queue
.
pop
();
lock
.
unlock
();
// warn if queue size greater than 75%
if
(
size
>
(
queue_size
*
0.75
))
{
wlog
(
"queue size: ${q}"
,
(
"q"
,
size
+
1
));
}
else
if
(
done
)
{
ilog
(
"draining queue, size: ${q}"
,
(
"q"
,
size
+
1
));
}
process_irreversible_block
(
block
);
continue
;
}
else
if
(
done
)
{
ilog
(
"draining queue, size: ${q}"
,
(
"q"
,
size
+
1
))
;
break
;
}
process_irreversible_block
(
block
);
continue
;
}
else
if
(
done
)
{
break
;
}
ilog
(
"db_plugin consum thread shutdown gracefully"
);
}
catch
(
fc
::
exception
&
e
)
{
elog
(
"FC Exception while consuming block ${e}"
,
(
"e"
,
e
.
to_string
()));
}
catch
(
std
::
exception
&
e
)
{
elog
(
"STD Exception while consuming block ${e}"
,
(
"e"
,
e
.
what
()));
}
catch
(...)
{
elog
(
"Unknown exception while consuming block"
);
}
ilog
(
"db_plugin consum thread shutdown gracefully"
);
}
namespace
{
...
...
@@ -575,7 +591,7 @@ void db_plugin_impl::init() {
////////////
db_plugin
::
db_plugin
()
:
my
(
n
ullptr
)
:
my
(
n
ew
db_plugin_impl
)
{
}
...
...
@@ -600,21 +616,17 @@ void db_plugin::set_program_options(options_description& cli, options_descriptio
void
db_plugin
::
wipe_database
()
{
#ifdef MONGODB
if
(
my
)
{
if
(
!
my
->
startup
)
{
elog
(
"ERROR: db_plugin::wipe_database() called before configuration or after startup. Ignoring."
);
}
else
{
my
->
wipe_database_on_startup
=
true
;
}
if
(
!
my
->
startup
)
{
elog
(
"ERROR: db_plugin::wipe_database() called before configuration or after startup. Ignoring."
);
}
else
{
my
->
wipe_database_on_startup
=
true
;
}
#endif
}
void
db_plugin
::
applied_irreversible_block
(
const
signed_block
&
block
)
{
#ifdef MONGODB
if
(
my
)
{
my
->
applied_irreversible_block
(
block
);
}
my
->
applied_irreversible_block
(
block
);
#endif
}
...
...
@@ -623,8 +635,8 @@ void db_plugin::plugin_initialize(const variables_map& options)
{
#ifdef MONGODB
if
(
options
.
count
(
"mongodb-uri"
))
{
my
.
reset
(
new
db_plugin_impl
);
ilog
(
"initializing db plugin"
);
my
->
configured
=
true
;
if
(
options
.
count
(
"filter-on-accounts"
))
{
auto
foa
=
options
.
at
(
"filter-on-accounts"
).
as
<
std
::
vector
<
std
::
string
>>
();
for
(
auto
filter_account
:
foa
)
...
...
@@ -647,8 +659,8 @@ void db_plugin::plugin_initialize(const variables_map& options)
}
my
->
init
();
}
else
{
i
log
(
"eos::db_plugin configured, but no --mongodb-uri specified."
);
i
log
(
"db_plugin disabled."
);
w
log
(
"eos::db_plugin configured, but no --mongodb-uri specified."
);
w
log
(
"db_plugin disabled."
);
}
#endif
}
...
...
@@ -656,7 +668,7 @@ void db_plugin::plugin_initialize(const variables_map& options)
void
db_plugin
::
plugin_startup
()
{
#ifdef MONGODB
if
(
my
)
{
if
(
my
->
configured
)
{
ilog
(
"starting db plugin"
);
my
->
consum_thread
=
boost
::
thread
([
this
]
{
my
->
consum_blocks
();
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录