Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
c67c6766
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,发现更多精彩内容 >>
提交
c67c6766
编写于
9月 17, 2018
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add wildcard support of receiver
上级
1eb7e9c5
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
34 addition
and
24 deletion
+34
-24
plugins/mongo_db_plugin/mongo_db_plugin.cpp
plugins/mongo_db_plugin/mongo_db_plugin.cpp
+34
-24
未找到文件。
plugins/mongo_db_plugin/mongo_db_plugin.cpp
浏览文件 @
c67c6766
...
@@ -53,11 +53,16 @@ struct filter_entry {
...
@@ -53,11 +53,16 @@ struct filter_entry {
name
receiver
;
name
receiver
;
name
action
;
name
action
;
name
actor
;
name
actor
;
std
::
tuple
<
name
,
name
,
name
>
key
()
const
{
return
std
::
make_tuple
(
receiver
,
action
,
actor
);
}
friend
bool
operator
<
(
const
filter_entry
&
a
,
const
filter_entry
&
b
)
{
friend
bool
operator
<
(
const
filter_entry
&
a
,
const
filter_entry
&
b
)
{
return
a
.
key
()
<
b
.
key
();
return
std
::
tie
(
a
.
receiver
,
a
.
action
,
a
.
actor
)
<
std
::
tie
(
b
.
receiver
,
b
.
action
,
b
.
actor
);
}
// receiver action actor
bool
match
(
const
name
&
rr
,
const
name
&
an
,
const
name
&
ar
)
const
{
return
(
receiver
.
value
==
0
||
receiver
==
rr
)
&&
(
action
.
value
==
0
||
action
==
an
)
&&
(
actor
.
value
==
0
||
actor
==
ar
);
}
}
};
};
...
@@ -214,32 +219,41 @@ const std::string mongo_db_plugin_impl::account_controls_col = "account_controls
...
@@ -214,32 +219,41 @@ const std::string mongo_db_plugin_impl::account_controls_col = "account_controls
bool
mongo_db_plugin_impl
::
filter_include
(
const
chain
::
action_trace
&
action_trace
)
const
{
bool
mongo_db_plugin_impl
::
filter_include
(
const
chain
::
action_trace
&
action_trace
)
const
{
bool
include
=
false
;
bool
include
=
false
;
if
(
filter_on_star
||
if
(
filter_on_star
)
{
filter_on
.
find
(
{
action_trace
.
receipt
.
receiver
,
0
,
0
}
)
!=
filter_on
.
end
()
||
include
=
true
;
filter_on
.
find
(
{
action_trace
.
receipt
.
receiver
,
action_trace
.
act
.
name
,
0
}
)
!=
filter_on
.
end
()
)
{
}
else
{
auto
itr
=
std
::
find_if
(
filter_on
.
cbegin
(),
filter_on
.
cend
(),
[
&
action_trace
](
const
auto
&
filter
)
{
return
filter
.
match
(
action_trace
.
receipt
.
receiver
,
action_trace
.
act
.
name
,
0
);
}
);
if
(
itr
!=
filter_on
.
cend
()
)
{
include
=
true
;
include
=
true
;
}
else
{
}
else
{
for
(
const
auto
&
a
:
action_trace
.
act
.
authorization
)
{
for
(
const
auto
&
a
:
action_trace
.
act
.
authorization
)
{
if
(
filter_on
.
find
(
{
action_trace
.
receipt
.
receiver
,
0
,
a
.
actor
}
)
!=
filter_on
.
end
()
||
auto
itr
=
std
::
find_if
(
filter_on
.
cbegin
(),
filter_on
.
cend
(),
[
&
action_trace
,
&
a
](
const
auto
&
filter
)
{
filter_on
.
find
(
{
action_trace
.
receipt
.
receiver
,
action_trace
.
act
.
name
,
a
.
actor
}
)
!=
filter_on
.
end
()
)
{
return
filter
.
match
(
action_trace
.
receipt
.
receiver
,
action_trace
.
act
.
name
,
a
.
actor
);
}
);
if
(
itr
!=
filter_on
.
cend
()
)
{
include
=
true
;
include
=
true
;
break
;
break
;
}
}
}
}
}
}
}
if
(
!
include
)
{
return
false
;
}
if
(
!
include
)
{
return
false
;
}
if
(
filter_out
.
find
(
{
action_trace
.
receipt
.
receiver
,
0
,
0
}
)
!=
filter_out
.
end
()
||
auto
itr
=
std
::
find_if
(
filter_out
.
cbegin
(),
filter_out
.
cend
(),
[
&
action_trace
](
const
auto
&
filter
)
{
filter_out
.
find
(
{
action_trace
.
receipt
.
receiver
,
action_trace
.
act
.
name
,
0
}
)
!=
filter_out
.
end
()
)
{
return
filter
.
match
(
action_trace
.
receipt
.
receiver
,
action_trace
.
act
.
name
,
0
);
return
false
;
}
);
}
if
(
itr
!=
filter_out
.
cend
()
)
{
return
false
;
}
for
(
const
auto
&
a
:
action_trace
.
act
.
authorization
)
{
for
(
const
auto
&
a
:
action_trace
.
act
.
authorization
)
{
if
(
filter_out
.
find
(
{
action_trace
.
receipt
.
receiver
,
0
,
a
.
actor
}
)
!=
filter_out
.
end
()
||
auto
itr
=
std
::
find_if
(
filter_out
.
cbegin
(),
filter_out
.
cend
(),
[
&
action_trace
,
&
a
](
const
auto
&
filter
)
{
filter_out
.
find
(
{
action_trace
.
receipt
.
receiver
,
action_trace
.
act
.
name
,
a
.
actor
}
)
!=
filter_out
.
end
()
)
{
return
filter
.
match
(
action_trace
.
receipt
.
receiver
,
action_trace
.
act
.
name
,
a
.
actor
);
return
false
;
}
)
;
}
if
(
itr
!=
filter_out
.
cend
()
)
{
return
false
;
}
}
}
return
true
;
return
true
;
}
}
...
@@ -1489,8 +1503,6 @@ void mongo_db_plugin::plugin_initialize(const variables_map& options)
...
@@ -1489,8 +1503,6 @@ void mongo_db_plugin::plugin_initialize(const variables_map& options)
boost
::
split
(
v
,
s
,
boost
::
is_any_of
(
":"
));
boost
::
split
(
v
,
s
,
boost
::
is_any_of
(
":"
));
EOS_ASSERT
(
v
.
size
()
==
3
,
fc
::
invalid_arg_exception
,
"Invalid value ${s} for --mongodb-filter-on"
,
(
"s"
,
s
));
EOS_ASSERT
(
v
.
size
()
==
3
,
fc
::
invalid_arg_exception
,
"Invalid value ${s} for --mongodb-filter-on"
,
(
"s"
,
s
));
filter_entry
fe
{
v
[
0
],
v
[
1
],
v
[
2
]};
filter_entry
fe
{
v
[
0
],
v
[
1
],
v
[
2
]};
EOS_ASSERT
(
fe
.
receiver
.
value
,
fc
::
invalid_arg_exception
,
"Invalid value ${s} for --mongodb-filter-on"
,
(
"s"
,
s
));
my
->
filter_on
.
insert
(
fe
);
my
->
filter_on
.
insert
(
fe
);
}
}
}
else
{
}
else
{
...
@@ -1503,8 +1515,6 @@ void mongo_db_plugin::plugin_initialize(const variables_map& options)
...
@@ -1503,8 +1515,6 @@ void mongo_db_plugin::plugin_initialize(const variables_map& options)
boost
::
split
(
v
,
s
,
boost
::
is_any_of
(
":"
));
boost
::
split
(
v
,
s
,
boost
::
is_any_of
(
":"
));
EOS_ASSERT
(
v
.
size
()
==
3
,
fc
::
invalid_arg_exception
,
"Invalid value ${s} for --mongodb-filter-out"
,
(
"s"
,
s
));
EOS_ASSERT
(
v
.
size
()
==
3
,
fc
::
invalid_arg_exception
,
"Invalid value ${s} for --mongodb-filter-out"
,
(
"s"
,
s
));
filter_entry
fe
{
v
[
0
],
v
[
1
],
v
[
2
]};
filter_entry
fe
{
v
[
0
],
v
[
1
],
v
[
2
]};
EOS_ASSERT
(
fe
.
receiver
.
value
,
fc
::
invalid_arg_exception
,
"Invalid value ${s} for --mongodb-filter-out"
,
(
"s"
,
s
));
my
->
filter_out
.
insert
(
fe
);
my
->
filter_out
.
insert
(
fe
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录