Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
8af3a16f
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,发现更多精彩内容 >>
提交
8af3a16f
编写于
1月 26, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Defining helper macros to simplify code.
上级
8d245066
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
55 addition
and
169 deletion
+55
-169
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+0
-130
contracts/eoslib/action.hpp
contracts/eoslib/action.hpp
+3
-0
contracts/eoslib/datastream.hpp
contracts/eoslib/datastream.hpp
+5
-1
contracts/eoslib/generic_currency.hpp
contracts/eoslib/generic_currency.hpp
+7
-38
contracts/eoslib/serialize.hpp
contracts/eoslib/serialize.hpp
+40
-0
未找到文件。
contracts/eosio.system/eosio.system.hpp
浏览文件 @
8af3a16f
...
...
@@ -10,136 +10,6 @@
namespace
eosiosystem
{
/**
* @defgroup eosio.system EOSIO System Contract
* @brief Defines the wasm components of the system contract
*
*/
/**
* We create the native EOSIO token type
*/
typedef
eosio
::
token
<
uint64_t
,
N
(
eosio
)
>
native_tokens
;
const
account_name
system_code
=
N
(
eosio
.
system
);
const
table_name
account_table
=
N
(
account
);
/**
* transfer requires that the sender and receiver be the first two
* accounts notified and that the sender has provided authorization.
* @abi action
*/
struct
transfer
{
/**
* account to transfer from
*/
account_name
from
;
/**
* account to transfer to
*/
account_name
to
;
/**
* quantity to transfer
*/
native_tokens
quantity
;
};
struct
transfer_memo
:
public
transfer
{
string
memo
;
};
/**
* This will transfer tokens from from.balance to to.vote_stake
*/
struct
stakevote
{
account_name
from
;
account_name
to
;
native_tokens
quantity
;
};
/**
* This table is used to track an individual user's token balance and vote stake.
*
*
* Location:
*
* {
* code: system_code
* scope: ${owner_account_name}
* table: N(singlton)
* key: N(account)
* }
*/
struct
account
{
/**
Constructor with default zero quantity (balance).
*/
account
(
native_tokens
b
=
native_tokens
()
)
:
balance
(
b
){}
/**
* The key is constant because there is only one record per scope/currency/accounts
*/
const
uint64_t
key
=
N
(
account
);
/**
* Balance number of tokens in account
**/
native_tokens
balance
;
native_tokens
vote_stake
;
native_tokens
proxied_vote_stake
;
uint64_t
last_vote_weight
=
0
;
//time_point last_stake_withdraw;
account_name
proxy
;
/**
Method to check if accoutn is empty.
@return true if account balance is zero.
**/
bool
is_empty
()
const
{
return
balance
.
quantity
==
0
;
}
};
struct
producer
{
account_name
key
;
/// producer name
uint64_t
votes
;
/// total votes received by producer
/// producer config...
};
struct
producer_vote
{
account_name
voter
;
account_name
producer
;
uint64_t
voteweight
=
0
;
};
/**
Defines the database table for account information
**/
using
accounts
=
eosio
::
table
<
N
(
unused
),
system_code
,
account_table
,
account
,
uint64_t
>
;
/**
* accounts information for owner is stored:
*
* owner/TOKEN_NAME/account/account -> account
*
* This API is made available for 3rd parties wanting read access to
* the users balance. If the account doesn't exist a default constructed
* account will be returned.
* @param owner The account owner
* @return account instance
*/
inline
account
get_account
(
account_name
owner
)
{
account
owned_account
;
/// scope, record
accounts
::
get
(
owned_account
,
owner
);
return
owned_account
;
}
}
/// eosiosystem
EOSLIB_REFLECT
(
eosiosystem
::
account
,
(
balance
)(
vote_stake
)(
proxied_vote_stake
)(
last_vote_weight
)(
proxy
)
)
EOSLIB_REFLECT
(
eosiosystem
::
transfer
,
(
from
)(
to
)(
quantity
)
)
EOSLIB_REFLECT
(
eosiosystem
::
stakevote
,
(
from
)(
to
)(
quantity
)
)
contracts/eoslib/action.hpp
浏览文件 @
8af3a16f
...
...
@@ -165,3 +165,6 @@ namespace eosio {
EOSLIB_REFLECT
(
eosio
::
permission_level
,
(
actor
)(
permission
)
)
EOSLIB_REFLECT
(
eosio
::
action
,
(
account
)(
name
)(
authorization
)(
data
)
)
#define ACTION( CODE, NAME ) struct NAME : action_meta<CODE, ::eosio::string_to_name(#NAME) >
contracts/eoslib/datastream.hpp
浏览文件 @
8af3a16f
...
...
@@ -6,6 +6,7 @@
#include <eoslib/system.h>
#include <eoslib/memory.h>
namespace
eosio
{
/**
* @brief A data stream for reading and writing data in the form of bytes
...
...
@@ -381,3 +382,6 @@ inline datastream<Stream>& operator>>(datastream<Stream>& ds, uint8_t& d) {
}
}
contracts/eoslib/generic_currency.hpp
浏览文件 @
8af3a16f
...
...
@@ -4,6 +4,7 @@
#include <eoslib/token.hpp>
#include <eoslib/asset.hpp>
#include <eoslib/dispatcher.hpp>
#include <eoslib/serialize.hpp>
namespace
eosio
{
...
...
@@ -16,22 +17,15 @@ namespace eosio {
static
const
uint64_t
accounts_table_name
=
N
(
account
);
static
const
uint64_t
stats_table_name
=
N
(
stat
);
struct
issue
:
action_meta
<
code
,
N
(
issue
)
>
{
ACTION
(
code
,
issue
)
{
typedef
action_meta
<
code
,
N
(
issue
)
>
meta
;
account_name
to
;
asset
quantity
;
template
<
typename
DataStream
>
friend
DataStream
&
operator
<<
(
DataStream
&
ds
,
const
issue
&
t
){
return
ds
<<
t
.
to
<<
t
.
quantity
;
}
template
<
typename
DataStream
>
friend
DataStream
&
operator
>>
(
DataStream
&
ds
,
issue
&
t
){
return
ds
>>
t
.
to
>>
t
.
quantity
;
}
EOSLIB_SERIALIZE
(
issue
,
(
to
)(
quantity
)
)
};
struct
transfer
:
action_meta
<
code
,
N
(
transfer
)
>
{
ACTION
(
code
,
transfer
)
{
transfer
(){}
transfer
(
account_name
f
,
account_name
t
,
token_type
q
)
:
from
(
f
),
to
(
t
),
quantity
(
q
){}
...
...
@@ -39,8 +33,6 @@ namespace eosio {
account_name
to
;
asset
quantity
;
//EOSLIB_SERIALIZE( transfer, (from)(to)(quantity)(symbol) )
template
<
typename
DataStream
>
friend
DataStream
&
operator
<<
(
DataStream
&
ds
,
const
transfer
&
t
){
return
ds
<<
t
.
from
<<
t
.
to
<<
t
.
quantity
;
...
...
@@ -60,44 +52,21 @@ namespace eosio {
string
memo
;
template
<
typename
DataStream
>
friend
DataStream
&
operator
<<
(
DataStream
&
ds
,
const
transfer_memo
&
t
){
ds
<<
static_cast
<
const
transfer
&>
(
t
);
return
ds
<<
t
.
memo
;
}
template
<
typename
DataStream
>
friend
DataStream
&
operator
>>
(
DataStream
&
ds
,
transfer_memo
&
t
){
ds
>>
static_cast
<
transfer
&>
(
t
);
return
ds
>>
t
.
memo
;
}
EOSLIB_SERIALIZE_DERIVED
(
transfer_memo
,
transfer
,
(
memo
)
)
};
struct
account
{
uint64_t
symbol
=
token_type
::
symbol
;
token_type
balance
;
template
<
typename
DataStream
>
friend
DataStream
&
operator
<<
(
DataStream
&
ds
,
const
account
&
t
){
return
ds
<<
t
.
symbol
<<
t
.
balance
;
}
template
<
typename
DataStream
>
friend
DataStream
&
operator
>>
(
DataStream
&
ds
,
account
&
t
){
return
ds
>>
t
.
symbol
>>
t
.
balance
;
}
EOSLIB_SERIALIZE
(
account
,
(
symbol
)(
balance
)
)
};
struct
currency_stats
{
uint64_t
symbol
=
token_type
::
symbol
;
token_type
supply
;
template
<
typename
DataStream
>
friend
DataStream
&
operator
<<
(
DataStream
&
ds
,
const
currency_stats
&
t
){
return
ds
<<
t
.
symbol
<<
t
.
supply
;
}
template
<
typename
DataStream
>
friend
DataStream
&
operator
>>
(
DataStream
&
ds
,
currency_stats
&
t
){
return
ds
>>
t
.
symbol
>>
t
.
supply
;
}
EOSLIB_SERIALIZE
(
currency_stats
,
(
symbol
)(
supply
)
)
};
/**
...
...
contracts/eoslib/serialize.hpp
0 → 100644
浏览文件 @
8af3a16f
#include <eoslib/preprocessor/seq/for_each.hpp>
#include <eoslib/preprocessor/seq/enum.hpp>
#include <eoslib/preprocessor/seq/size.hpp>
#include <eoslib/preprocessor/seq/seq.hpp>
#include <eoslib/preprocessor/stringize.hpp>
#define EOSLIB_REFLECT_MEMBER_OP( r, OP, elem ) \
OP t.elem
/**
* @def EOSLIB_SERIALIZE(TYPE,MEMBERS)
*
* @brief Specializes eosio::reflector for TYPE where
* type inherits other reflected classes
*
* @param INHERITS - a sequence of base class names (basea)(baseb)(basec)
* @param MEMBERS - a sequence of member names. (field1)(field2)(field3)
*/
#define EOSLIB_SERIALIZE( TYPE, MEMBERS ) \
template<typename DataStream> \
friend DataStream& operator << ( DataStream& ds, const TYPE& t ){ \
return ds BOOST_PP_SEQ_FOR_EACH( EOSLIB_REFLECT_MEMBER_OP, <<, MEMBERS );\
}\
template<typename DataStream> \
friend DataStream& operator >> ( DataStream& ds, TYPE& t ){ \
return ds BOOST_PP_SEQ_FOR_EACH( EOSLIB_REFLECT_MEMBER_OP, >>, MEMBERS );\
}
#define EOSLIB_SERIALIZE_DERIVED( TYPE, BASE, MEMBERS ) \
template<typename DataStream> \
friend DataStream& operator << ( DataStream& ds, const TYPE& t ){ \
ds << static_cast<const BASE&>(t); \
return ds BOOST_PP_SEQ_FOR_EACH( EOSLIB_REFLECT_MEMBER_OP, <<, MEMBERS );\
}\
template<typename DataStream> \
friend DataStream& operator >> ( DataStream& ds, TYPE& t ){ \
ds >> static_cast<BASE&>(t); \
return ds BOOST_PP_SEQ_FOR_EACH( EOSLIB_REFLECT_MEMBER_OP, >>, MEMBERS );\
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录