Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
9baf84ad
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,发现更多精彩内容 >>
提交
9baf84ad
编写于
1月 03, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
started implementation of eosio.system contract as wasm contract
上级
49ea3373
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
295 addition
and
5 deletion
+295
-5
contracts/CMakeLists.txt
contracts/CMakeLists.txt
+1
-0
contracts/eosio.system/CMakeLists.txt
contracts/eosio.system/CMakeLists.txt
+3
-0
contracts/eosio.system/README.md
contracts/eosio.system/README.md
+84
-0
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+37
-0
contracts/eosio.system/eosio.system.cpp
contracts/eosio.system/eosio.system.cpp
+52
-0
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+116
-0
contracts/eoslib/token.hpp
contracts/eoslib/token.hpp
+2
-5
未找到文件。
contracts/CMakeLists.txt
浏览文件 @
9baf84ad
add_subdirectory
(
eosio.system
)
add_subdirectory
(
asserter
)
add_subdirectory
(
currency
)
add_subdirectory
(
exchange
)
...
...
contracts/eosio.system/CMakeLists.txt
0 → 100644
浏览文件 @
9baf84ad
file
(
GLOB ABI_FILES
"*.abi"
)
configure_file
(
"
${
ABI_FILES
}
"
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
COPYONLY
)
add_wast_target
(
eosio.system
"
${
CMAKE_SOURCE_DIR
}
/contracts"
${
CMAKE_CURRENT_BINARY_DIR
}
)
contracts/eosio.system/README.md
0 → 100644
浏览文件 @
9baf84ad
eosio.system
----------
This contract enables users to stake tokens, and then configure and vote on producers and worker proposals.
Users can also proxy their voting influence to other users.
The state of this contract is read to determine the 21 active block producers.
Actions:
The naming convention is codeaccount::actionname followed by a list of paramters.
Indicates that a particular account wishes to become a producer
## eosio.system::cfgproducer account config
-
**account**
the producer account to update
-
updates the configuration settings for a particular producer, these
Storage changes are billed to 'account'
## eosio.system::okproducer account producer vote
-
**account**
the account which is doing the voting
-
**producer**
the producer which is being voted for (or unvoted for)
-
**vote**
true if the producer should be voted for, false if not
Each account has a maximum number of votes it can maintain. Storage changes will be billed to 'account'
## eosio.system::setproxy account proxy
-
**account**
the account which is updating it's proxy
-
**proxy**
the account which will have the power to vote account's stake
All current votes are removed and a new proxy link is created. The votes for every producer the proxy
has voted for are updated immediately.
Storage changes will be billed to 'account'
## eosio.system::unstake account quantity
-
**account**
- the account which is requsting their balance be unstaked
-
**quantity**
- the quantity which will be unstaked, unstaked tokens lose voting influence immediately
-
in order to unstake tokens, an account must request them. The user will receive them over
time via weekly withdraws. The length of time will be configured by the median time as set by
the active producers.
-
If this is called while in the process of unstaking, the currently pending unstake is canceled as if
quantity were 0, then it is applied as if a new unstake request was made.
-
all producers this 'from' has voted for will have their votes updated immediately.
-
bandwidth and storage for the deferred transaction will be billed to 'from'
## eosio.system::withdraw account
-
this action can only be triggered by eosio.system via a deferred transaction generated by unstake
-
this will generate an inline eosio.token::transfer call from=eosio.system to=account and amount equal to the next withdraw increment
-
this will generate another deferred withdraw to continue the process if there are still withdraws to be made
## eosio.system::transfer from to amount memo
-
decrements balance of from if amount <= balance
-
increments balance of to by amount
-
memo is ignored
## eosio.system::stakevote account amount
-
the primary currency of eosio is controlled by the token contract which enables users to transfer
balances from one user to another. The receiver is notified on incoming balances and the vote contract
will stake the tokens on receipt.
-
all producers this 'from' has voted for will have their votes updated immediately.
## eosio.system::onblock account blocktime blocknum
-
this special action is triggered when a block is applied by the given producer and cannot be generated from
any other source. It is used to pay producers and calculate missed blocks of other producers.
-
producer pay is deposited into the prodcer's stake balance and can be withdrawn over time.
-
if blocknum is the start of a new round this may update the active producer config from the producer votes.
## eosio.system::freeze producer accounts true|false
-
requires permission of the @producers account
-
if an account is frozen, all authorizations of that account are rejected and the code for that account will not be run
## eosio.system::paystandby producer
-
every block some amount of tokens is paid
-
at most once per day a producer may claim a percentage of the standby pay equal to their totalvotes / allvotes
contracts/eosio.system/eosio.system.abi
0 → 100644
浏览文件 @
9baf84ad
{
"types": [{
"new_type_name": "account_name",
"type": "name"
}
],
"structs": [{
"name": "transfer",
"base": "",
"fields": [
{"name":"from", "type":"account_name"},
{"name":"to", "type":"account_name"},
{"name":"quantity", "type":"uint64"}
]
},{
"name": "account",
"base": "",
"fields": [
{"name":"key", "type":"name"},
{"name":"balance", "type":"uint64"}
]
}
],
"actions": [{
"name": "transfer",
"type": "transfer"
}
],
"tables": [{
"name": "account",
"type": "account",
"index_type": "i64",
"key_names" : ["key"],
"key_types" : ["name"]
}
]
}
\ No newline at end of file
contracts/eosio.system/eosio.system.cpp
0 → 100644
浏览文件 @
9baf84ad
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <eosio.system/eosio.system.hpp>
namespace
eosiosystem
{
using
namespace
eosio
;
/// When storing accounts, check for empty balance and remove account
void
store_account
(
account_name
account_to_store
,
const
account
&
a
)
{
/// value, scope
accounts
::
store
(
a
,
account_to_store
);
}
void
on
(
const
eosiosystem
::
transfer
&
transfer_msg
)
{
require_recipient
(
transfer_msg
.
to
,
transfer_msg
.
from
);
require_auth
(
transfer_msg
.
from
);
auto
from
=
get_account
(
transfer_msg
.
from
);
auto
to
=
get_account
(
transfer_msg
.
to
);
from
.
balance
-=
transfer_msg
.
quantity
;
/// token subtraction has underflow assertion
to
.
balance
+=
transfer_msg
.
quantity
;
/// token addition has overflow assertion
store_account
(
transfer_msg
.
from
,
from
);
store_account
(
transfer_msg
.
to
,
to
);
}
void
init
()
{
// TODO verify that
//store_account( system_name, account( native_tokens(1000ll*1000ll*1000ll) ) );
}
}
// namespace eosiosystem
using
namespace
eosiosystem
;
extern
"C"
{
/// The apply method implements the dispatch of events to this contract
void
apply
(
uint64_t
code
,
uint64_t
action
)
{
if
(
code
==
system_code
)
{
if
(
action
==
N
(
init
)
)
{
init
();
}
else
if
(
action
==
N
(
transfer
)
)
{
on
(
current_action
<
eosiosystem
::
transfer
>
()
);
}
}
}
}
contracts/eosio.system/eosio.system.hpp
0 → 100644
浏览文件 @
9baf84ad
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <eoslib/eos.hpp>
#include <eoslib/token.hpp>
#include <eoslib/db.hpp>
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
;
};
/**
* @brief row in account table stored within each scope
* @abi table
*/
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
;
}
}
/// @} /// currencyapi
contracts/eoslib/token.hpp
浏览文件 @
9baf84ad
...
...
@@ -56,13 +56,13 @@ namespace eosio {
*
* @{
*/
template
<
typename
NumberType
,
uint64_t
c
urrency
=
N
(
eos
)
>
template
<
typename
NumberType
,
uint64_t
C
urrency
=
N
(
eos
)
>
struct
token
{
/**
* Type of the currency (e.g. eos) represented as an unsigned 64 bit integer
* @brief Type of the currency
*/
static
const
uint64_t
currency_type
=
c
urrency
;
static
const
uint64_t
currency_type
=
C
urrency
;
/**
* Default constructor
...
...
@@ -289,7 +289,6 @@ namespace eosio {
* @return quote token
*/
friend
QuoteToken
operator
/
(
BaseToken
b
,
const
price
&
q
)
{
eosio
::
print
(
"operator/ "
,
uint128
(
b
.
quantity
),
" * "
,
uint128
(
precision
),
" / "
,
q
.
base_per_quote
,
"
\n
"
);
return
QuoteToken
(
uint64_t
((
uint128
(
b
.
quantity
)
*
uint128
(
precision
)
/
q
.
base_per_quote
))
);
}
...
...
@@ -301,8 +300,6 @@ namespace eosio {
* @return base token
*/
friend
BaseToken
operator
*
(
const
QuoteToken
&
b
,
const
price
&
q
)
{
eosio
::
print
(
"b: "
,
b
,
"
\n
"
);
eosio
::
print
(
"operator* "
,
uint128
(
b
.
quantity
),
" * "
,
uint128
(
q
.
base_per_quote
),
" / "
,
precision
,
"
\n
"
);
//return QuoteToken( uint64_t( mult_div_i128( b.quantity, q.base_per_quote, precision ) ) );
return
BaseToken
(
uint64_t
((
b
.
quantity
*
q
.
base_per_quote
)
/
precision
)
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录