Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
72cecfcc
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,发现更多精彩内容 >>
提交
72cecfcc
编写于
10月 10, 2017
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ability to build without mongodb #172
上级
3962475a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
21 deletion
+43
-21
plugins/db_plugin/CMakeLists.txt
plugins/db_plugin/CMakeLists.txt
+22
-20
plugins/db_plugin/db_plugin.cpp
plugins/db_plugin/db_plugin.cpp
+21
-1
未找到文件。
plugins/db_plugin/CMakeLists.txt
浏览文件 @
72cecfcc
...
...
@@ -3,36 +3,38 @@ add_library( db_plugin
db_plugin.cpp
${
HEADERS
}
)
find_package
(
libmongoc-1.0 1.8
REQUIRED
)
find_package
(
libmongoc-1.0 1.8
)
message
(
"-- mongoc found version
\"
${
MONGOC_VERSION
}
\"
"
)
message
(
"-- mongoc include path
\"
${
MONGOC_INCLUDE_DIRS
}
\"
"
)
message
(
"-- mongoc libraries
\"
${
MONGOC_LIBRARIES
}
\"
"
)
if
(
libmongoc-1.0_FOUND
)
find_package
(
PkgConfig QUIET
)
message
(
"-- mongoc found version
\"
${
MONGOC_VERSION
}
\"
"
)
message
(
"-- mongoc include path
\"
${
MONGOC_INCLUDE_DIRS
}
\"
"
)
message
(
"-- mongoc libraries
\"
${
MONGOC_LIBRARIES
}
\"
"
)
# NOTE: For this to work, the PKG_CONFIG_PATH variable (man pkg-config) must be set to point to the
# 'lib/pkgconfig' subdirectory of the directory used as the argument to CMAKE_INSTALL_PREFIX when
# building libmongocxx and libbsoncxx.
pkg_search_module
(
BSONCXX REQUIRED libbsoncxx
)
pkg_search_module
(
MONGOCXX REQUIRED libmongocxx
)
find_package
(
PkgConfig QUIET
)
link_directories
(
${
MONGOCXX_LIBRARY_DIRS
}
${
BSONCXX_LIBRARY_DIRS
}
)
# NOTE: For this to work, the PKG_CONFIG_PATH variable (man pkg-config) must be set to point to the
# 'lib/pkgconfig' subdirectory of the directory used as the argument to CMAKE_INSTALL_PREFIX when
# building libmongocxx and libbsoncxx.
pkg_search_module
(
BSONCXX REQUIRED libbsoncxx
)
pkg_search_module
(
MONGOCXX REQUIRED libmongocxx
)
link_directories
(
${
MONGOCXX_LIBRARY_DIRS
}
${
BSONCXX_LIBRARY_DIRS
}
)
add_definitions
(
-DMONGODB
)
endif
()
target_include_directories
(
db_plugin
target_include_directories
(
db_plugin
PRIVATE
${
MONGOCXX_INCLUDE_DIRS
}
PRIVATE
${
BSONCXX_INCLUDE_DIRS
}
PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
)
target_link_libraries
(
db_plugin
)
target_link_libraries
(
db_plugin
PUBLIC chain_plugin eos_chain appbase
PRIVATE
${
MONGOCXX_LIBRARIES
}
${
BSONCXX_LIBRARIES
}
)
)
install
(
TARGETS
db_plugin
...
...
plugins/db_plugin/db_plugin.cpp
浏览文件 @
72cecfcc
...
...
@@ -11,6 +11,7 @@
#include <boost/thread/thread.hpp>
#include <boost/lockfree/spsc_queue.hpp>
#ifdef MONGODB
#include <bsoncxx/builder/basic/kvp.hpp>
#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/builder/stream/document.hpp>
...
...
@@ -18,6 +19,7 @@
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#endif
namespace
fc
{
class
variant
;
}
...
...
@@ -31,6 +33,14 @@ using chain::ProcessedTransaction;
using
chain
::
signed_block
;
using
chain
::
transaction_id_type
;
#ifndef MONGODB
class
db_plugin_impl
{
public:
db_plugin_impl
()
{}
};
#endif
#ifdef MONGODB
class
db_plugin_impl
{
public:
db_plugin_impl
();
...
...
@@ -523,6 +533,7 @@ void db_plugin_impl::init() {
}
}
#endif
/* MONGODB */
////////////
// db_plugin
////////////
...
...
@@ -538,6 +549,7 @@ db_plugin::~db_plugin()
void
db_plugin
::
set_program_options
(
options_description
&
cli
,
options_description
&
cfg
)
{
#ifdef MONGODB
cfg
.
add_options
()
(
"filter-on-accounts,f"
,
bpo
::
value
<
std
::
vector
<
std
::
string
>>
()
->
composing
(),
"Track only transactions whose scopes involve the listed accounts. Default is to track all transactions."
)
...
...
@@ -546,23 +558,29 @@ void db_plugin::set_program_options(options_description& cli, options_descriptio
(
"mongodb-uri,m"
,
bpo
::
value
<
std
::
string
>
()
->
default_value
(
"mongodb://localhost:27017"
),
"MongoDB URI connection string, see: https://docs.mongodb.com/master/reference/connection-string/"
)
;
#endif
}
void
db_plugin
::
wipe_database
()
{
#ifdef MONGODB
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
my
->
applied_irreversible_block
(
block
);
#endif
}
void
db_plugin
::
plugin_initialize
(
const
variables_map
&
options
)
{
#ifdef MONGODB
ilog
(
"initializing db plugin"
);
if
(
options
.
count
(
"filter-on-accounts"
))
{
auto
foa
=
options
.
at
(
"filter-on-accounts"
).
as
<
std
::
vector
<
std
::
string
>>
();
...
...
@@ -582,17 +600,19 @@ void db_plugin::plugin_initialize(const variables_map& options)
my
->
wipe_database
();
}
my
->
init
();
#endif
}
void
db_plugin
::
plugin_startup
()
{
#ifdef MONGODB
ilog
(
"starting db plugin"
);
// TODO: assert that last irreversible in db is one less than received (on startup only?, every so often?)
my
->
consum_thread
=
boost
::
thread
([
this
]{
my
->
consum_blocks
();
});
// chain_controller is created and has resynced or replayed if needed
my
->
startup
=
false
;
#endif
}
void
db_plugin
::
plugin_shutdown
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录