Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
cbc7793a
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,发现更多精彩内容 >>
提交
cbc7793a
编写于
4月 26, 2017
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
progress
上级
4cfcb97b
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
54 addition
and
17 deletion
+54
-17
libraries/chain/database.cpp
libraries/chain/database.cpp
+12
-0
libraries/chain/include/eos/chain/account_object.hpp
libraries/chain/include/eos/chain/account_object.hpp
+36
-15
libraries/chain/include/eos/chain/database.hpp
libraries/chain/include/eos/chain/database.hpp
+1
-0
libraries/chain/include/eos/chain/protocol/types.hpp
libraries/chain/include/eos/chain/protocol/types.hpp
+2
-0
tests/tests/block_tests.cpp
tests/tests/block_tests.cpp
+3
-2
未找到文件。
libraries/chain/database.cpp
浏览文件 @
cbc7793a
...
...
@@ -508,6 +508,16 @@ void database::validate_referenced_accounts( const signed_transaction& trx )cons
}
}
}
void
database
::
validate_message_types
(
const
signed_transaction
&
trx
)
const
{
try
{
for
(
const
auto
&
msg
:
trx
.
messages
)
{
try
{
get
<
message_object
,
by_scope_name
>
(
boost
::
make_tuple
(
msg
.
recipient
,
msg
.
type
)
);
}
FC_CAPTURE_AND_RETHROW
(
(
msg
.
recipient
)(
msg
.
type
)
)
}
}
FC_CAPTURE_AND_RETHROW
(
(
trx
)
)
}
void
database
::
validate_transaction
(
const
signed_transaction
&
trx
)
const
{
try
{
FC_ASSERT
(
trx
.
messages
.
size
()
>
0
,
"A transaction must have at least one message"
);
...
...
@@ -515,6 +525,7 @@ try {
validate_uniqueness
(
trx
);
validate_tapos
(
trx
);
validate_referenced_accounts
(
trx
);
validate_message_types
(
trx
);
for
(
const
auto
&
m
:
trx
.
messages
)
{
/// TODO: this loop can be processed in parallel
message_validate_context
mvc
(
trx
,
m
);
...
...
@@ -686,6 +697,7 @@ void database::initialize_indexes() {
add_index
<
permission_index
>
();
add_index
<
action_code_index
>
();
add_index
<
action_permission_index
>
();
add_index
<
message_index
>
();
add_index
<
global_property_multi_index
>
();
add_index
<
dynamic_global_property_multi_index
>
();
...
...
libraries/chain/include/eos/chain/account_object.hpp
浏览文件 @
cbc7793a
...
...
@@ -63,14 +63,13 @@ namespace eos { namespace chain {
class
permission_object
:
public
chainbase
::
object
<
permission_object_type
,
permission_object
>
{
OBJECT_CTOR
(
permission_object
,
(
name
)
)
OBJECT_CTOR
(
permission_object
,
(
auth
)
)
id_type
id
;
account_id_type
owner
;
///< the account this permission belongs to
id_type
parent
;
///< parent permission
shared_string
name
;
#warning TODO - add shared_authority to permission object
// shared_authority auth; ///< TODO
permission_name
name
;
shared_authority
auth
;
///< TODO
};
...
...
@@ -93,7 +92,7 @@ namespace eos { namespace chain {
member
<
permission_object
,
permission_object
::
id_type
,
&
permission_object
::
id
>
>
>
,
ordered_unique
<
tag
<
by_name
>
,
member
<
permission_object
,
shared_string
,
&
permission_object
::
name
>
,
chainbase
::
strcmp_less
>
ordered_unique
<
tag
<
by_name
>
,
member
<
permission_object
,
permission_name
,
&
permission_object
::
name
>
>
>
>
;
...
...
@@ -103,14 +102,13 @@ namespace eos { namespace chain {
*/
class
action_code_object
:
public
chainbase
::
object
<
action_code_object_type
,
action_code_object
>
{
OBJECT_CTOR
(
action_code_object
,
(
action
)(
validate_action
)(
validate_precondition
)(
apply
)
)
OBJECT_CTOR
(
action_code_object
,
(
validate_action
)(
validate_precondition
)(
apply
)
)
id_type
id
;
account_id_type
scope
;
permission_object
::
id_type
permission
;
#warning TODO: convert action name to fixed with string
shared_string
action
;
///< the name of the action (defines serialization)
message_type
action
;
///< the name of the action (defines serialization)
shared_string
validate_action
;
///< read only access to action
shared_string
validate_precondition
;
///< read only access to state
shared_string
apply
;
///< the code that executes the state transition
...
...
@@ -125,9 +123,8 @@ namespace eos { namespace chain {
ordered_unique
<
tag
<
by_scope_action
>
,
composite_key
<
action_code_object
,
member
<
action_code_object
,
account_id_type
,
&
action_code_object
::
scope
>
,
member
<
action_code_object
,
shared_string
,
&
action_code_object
::
action
>
>
,
composite_key_compare
<
std
::
less
<
account_id_type
>
,
chainbase
::
strcmp_less
>
member
<
action_code_object
,
message_type
,
&
action_code_object
::
action
>
>
>
>
>
;
...
...
@@ -180,14 +177,38 @@ namespace eos { namespace chain {
>
>
;
struct
message_object
:
public
chainbase
::
object
<
message_object_type
,
message_object
>
{
public:
id_type
id
;
account_name
scope
;
message_type
name
;
};
struct
by_scope_name
;
using
message_index
=
chainbase
::
shared_multi_index_container
<
message_object
,
indexed_by
<
ordered_unique
<
tag
<
by_id
>
,
member
<
message_object
,
message_object
::
id_type
,
&
message_object
::
id
>>
,
ordered_unique
<
tag
<
by_scope_name
>
,
composite_key
<
message_object
,
member
<
message_object
,
account_name
,
&
message_object
::
scope
>
,
member
<
message_object
,
message_type
,
&
message_object
::
name
>
>
>
>
>
;
}
}
// eos::chain
CHAINBASE_SET_INDEX_TYPE
(
eos
::
chain
::
account_object
,
eos
::
chain
::
account_index
)
CHAINBASE_SET_INDEX_TYPE
(
eos
::
chain
::
permission_object
,
eos
::
chain
::
permission_index
)
CHAINBASE_SET_INDEX_TYPE
(
eos
::
chain
::
action_code_object
,
eos
::
chain
::
action_code_index
)
CHAINBASE_SET_INDEX_TYPE
(
eos
::
chain
::
action_permission_object
,
eos
::
chain
::
action_permission_index
)
CHAINBASE_SET_INDEX_TYPE
(
eos
::
chain
::
message_object
,
eos
::
chain
::
message_index
)
FC_REFLECT
(
eos
::
chain
::
account_object
,
(
id
)(
name
)(
balance
)(
votes
)(
converting_votes
)(
last_vote_conversion
)
)
FC_REFLECT
(
eos
::
chain
::
permission_object
,
(
id
)(
owner
)(
parent
)(
name
)
)
FC_REFLECT
(
eos
::
chain
::
action_code_object
,
(
id
)(
scope
)(
permission
)(
action
)(
validate_action
)(
validate_precondition
)(
apply
)
)
FC_REFLECT
(
eos
::
chain
::
action_permission_object
,
(
id
)(
owner
)(
owner_permission
)(
scope_permission
)
)
FC_REFLECT
(
eos
::
chain
::
message_object
,
(
id
)(
scope
)(
name
)
)
libraries/chain/include/eos/chain/database.hpp
浏览文件 @
cbc7793a
...
...
@@ -317,6 +317,7 @@ namespace eos { namespace chain {
void
validate_transaction
(
const
signed_transaction
&
trx
)
const
;
void
validate_tapos
(
const
signed_transaction
&
trx
)
const
;
void
validate_referenced_accounts
(
const
signed_transaction
&
trx
)
const
;
void
validate_message_types
(
const
signed_transaction
&
trx
)
const
;
optional
<
session
>
_pending_tx_session
;
...
...
libraries/chain/include/eos/chain/protocol/types.hpp
浏览文件 @
cbc7793a
...
...
@@ -125,6 +125,7 @@ namespace eos { namespace chain {
account_object_type
,
permission_object_type
,
action_code_object_type
,
message_object_type
,
action_permission_object_type
,
global_property_object_type
,
dynamic_global_property_object_type
,
...
...
@@ -192,6 +193,7 @@ FC_REFLECT_ENUM( eos::chain::object_type,
(
account_object_type
)
(
permission_object_type
)
(
action_code_object_type
)
(
message_object_type
)
(
action_permission_object_type
)
(
global_property_object_type
)
(
dynamic_global_property_object_type
)
...
...
tests/tests/block_tests.cpp
浏览文件 @
cbc7793a
...
...
@@ -70,6 +70,9 @@ BOOST_FIXTURE_TEST_CASE(transfer, testing_fixture)
trx
.
set_expiration
(
db
.
head_block_time
()
);
trx
.
messages
[
0
].
sender
=
"init1"
;
trx
.
messages
[
0
].
recipient
=
"sys"
;
trx
.
messages
[
0
].
type
=
"Undefined"
;
BOOST_REQUIRE_THROW
(
db
.
push_transaction
(
trx
),
fc
::
assert_exception
);
// "Type Undefined is not defined"
trx
.
messages
[
0
].
type
=
"Transfer"
;
trx
.
messages
[
0
].
set
(
"Transfer"
,
eos
::
chain
::
Transfer
{
"init2"
,
100
,
"memo"
}
);
BOOST_REQUIRE_THROW
(
db
.
push_transaction
(
trx
),
fc
::
assert_exception
);
// "fail to notify receiver, init2"
...
...
@@ -83,8 +86,6 @@ BOOST_FIXTURE_TEST_CASE(transfer, testing_fixture)
BOOST_REQUIRE_THROW
(
db
.
push_transaction
(
trx
),
fc
::
assert_exception
);
/// no messages
}
FC_LOG_AND_RETHROW
()
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录