Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
106a2997
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,发现更多精彩内容 >>
提交
106a2997
编写于
3月 07, 2018
作者:
A
Anton Perkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
system contract fixes
上级
18689431
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
72 addition
and
52 deletion
+72
-52
contracts/eosio.system/common.hpp
contracts/eosio.system/common.hpp
+10
-5
contracts/eosio.system/delegate_bandwith.hpp
contracts/eosio.system/delegate_bandwith.hpp
+5
-5
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+30
-2
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+1
-1
contracts/eosio.system/voting.hpp
contracts/eosio.system/voting.hpp
+22
-36
contracts/eosiolib/privileged.hpp
contracts/eosiolib/privileged.hpp
+4
-3
未找到文件。
contracts/eosio.system/common.hpp
浏览文件 @
106a2997
...
...
@@ -18,17 +18,22 @@ namespace eosiosystem {
struct
eosio_parameters
:
eosio
::
blockchain_parameters
{
uint32_t
inflation_rate
=
0
;
// inflation coefficient * 10000 (i.e. inflation in percent * 100)
uint32_t
storage_reserve_ratio
=
1000
;
// ratio * 1000
EOSLIB_SERIALIZE_DERIVED
(
eosio_parameters
,
eosio
::
blockchain_parameters
,
(
inflation_rate
)(
storage_reserve_ratio
)
(
storage_reserve_ratio
)
)
};
struct
eosio_global_state
:
eosio_parameters
{
uint64_t
total_storage_bytes_reserved
=
0
;
system_token_type
total_storage_stake
;
EOSLIB_SERIALIZE_DERIVED
(
eosio_parameters
,
eosio
::
blockchain_parameters
,
(
inflation_rate
)(
storage_reserve_ratio
)
(
storage_reserve_ratio
)(
total_storage_bytes_reserved
)(
total_storage_stake
)
)
EOSLIB_SERIALIZE_DERIVED
(
eosio_global_state
,
eosio_parameters
,
(
total_storage_bytes_reserved
)(
total_storage_stake
)
)
};
typedef
eosio
::
singleton
<
SystemAccount
,
N
(
inflation
),
SystemAccount
,
eosio_
parameters
>
eosio_parameters
_singleton
;
typedef
eosio
::
singleton
<
SystemAccount
,
N
(
inflation
),
SystemAccount
,
eosio_
global_state
>
global_state
_singleton
;
static
eosio_
parameters
&
get_default_parameters
()
{
static
eosio_
parameters
dp
;
static
eosio_
global_state
&
get_default_parameters
()
{
static
eosio_
global_state
dp
;
get_blockchain_parameters
(
&
dp
);
return
dp
;
}
...
...
contracts/eosio.system/delegate_bandwith.hpp
浏览文件 @
106a2997
...
...
@@ -33,7 +33,7 @@ namespace eosiosystem {
using
currency
=
typename
common
<
SystemAccount
>::
currency
;
using
system_token_type
=
typename
common
<
SystemAccount
>::
system_token_type
;
using
eosio_parameters
=
typename
common
<
SystemAccount
>::
eosio_parameters
;
using
eosio_parameters_singleton
=
typename
common
<
SystemAccount
>::
eosio_parameters
_singleton
;
using
global_state_singleton
=
typename
common
<
SystemAccount
>::
global_state
_singleton
;
struct
total_resources
{
account_name
owner
;
...
...
@@ -113,7 +113,7 @@ namespace eosiosystem {
//eosio_assert( is_account( del.receiver ), "can only delegate resources to an existing account" );
auto
parameters
=
eosio_parameters_singleton
::
exists
()
?
eosio_parameters
_singleton
::
get
()
auto
parameters
=
global_state_singleton
::
exists
()
?
global_state
_singleton
::
get
()
:
common
<
SystemAccount
>::
get_default_parameters
();
auto
token_supply
=
currency
::
get_total_supply
();
//.quantity;
...
...
@@ -174,7 +174,7 @@ namespace eosiosystem {
parameters
.
total_storage_bytes_reserved
+=
storage_bytes
;
parameters
.
total_storage_stake
+=
del
.
stake_storage_quantity
;
eosio_parameters
_singleton
::
set
(
parameters
);
global_state
_singleton
::
set
(
parameters
);
}
// delegatebw
static
void
on
(
const
undelegatebw
&
del
)
{
...
...
@@ -221,10 +221,10 @@ namespace eosiosystem {
/// TODO: implement / enforce time delays on withdrawing
currency
::
inline_transfer
(
SystemAccount
,
del
.
from
,
asset
(
static_cast
<
int64_t
>
(
total_refund
.
quantity
)),
"unstake bandwidth"
);
auto
parameters
=
eosio_parameters
_singleton
::
get
();
auto
parameters
=
global_state
_singleton
::
get
();
parameters
.
total_storage_bytes_reserved
-=
del
.
unstake_storage_bytes
;
parameters
.
total_storage_stake
-=
storage_stake_decrease
;
eosio_parameters
_singleton
::
set
(
parameters
);
global_state
_singleton
::
set
(
parameters
);
}
// undelegatebw
};
}
contracts/eosio.system/eosio.system.abi
浏览文件 @
106a2997
...
...
@@ -75,12 +75,40 @@
{"name":"storage_stake", "type":"uint64"},
{"name":"storage_bytes", "type":"uint64"}
]
},{
"name": "eosio_parameters",
"base": "",
"fields": [
{"name":"target_block_size", "type":"uint32"},
{"name":"max_block_size", "type":"uint32"},
{"name":"target_block_acts_per_scope", "type":"uint32"},
{"name":"max_block_acts_per_scope", "type":"uint32"},
{"name":"target_block_acts", "type":"uint32"},
{"name":"max_block_acts", "type":"uint32"},
{"name":"max_storage_size", "type":"uint64"},
{"name":"max_transaction_lifetime", "type":"uint32"},
{"name":"max_transaction_exec_time", "type":"uint32"},
{"name":"max_authority_depth", "type":"uint16"},
{"name":"max_inline_depth", "type":"uint16"},
{"name":"max_inline_action_size", "type":"uint32"},
{"name":"max_generated_transaction_size", "type":"uint32"},
{"name":"inflation_rate", "type":"uint32"},
{"name":"storage_reserve_ratio", "type":"uint32"},
]
},,{
"name": "eosio_global_state",
"base": "eosio_parameters",
"fields": [
{"name":"total_storage_bytes_reserved", "type":"uint64"},
{"name":"total_storage_stake", "type":"uint64"}
]
},{
"name": "regproducer",
"base": "",
"fields": [
{"name":"producer", "type":"account_name"},
{"name":"producer_key", "type":"bytes"}
{"name":"producer_key", "type":"bytes"},
{"name":"prefs", "type":"eosio_parameters"}
]
},{
"name": "stakevote",
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
106a2997
...
...
@@ -35,7 +35,7 @@ namespace eosiosystem {
typename
delegate_bandwith
<
SystemAccount
>::
undelegatebw
,
typename
voting
<
SystemAccount
>::
register_proxy
,
typename
voting
<
SystemAccount
>::
unregister_proxy
,
typename
voting
<
SystemAccount
>::
reg
ister_
producer
,
typename
voting
<
SystemAccount
>::
regproducer
,
typename
voting
<
SystemAccount
>::
vote_producer
,
typename
voting
<
SystemAccount
>::
stakevote
,
typename
voting
<
SystemAccount
>::
unstakevote
,
...
...
contracts/eosio.system/voting.hpp
浏览文件 @
106a2997
...
...
@@ -36,7 +36,7 @@ namespace eosiosystem {
using
currency
=
typename
common
<
SystemAccount
>::
currency
;
using
system_token_type
=
typename
common
<
SystemAccount
>::
system_token_type
;
using
eosio_parameters
=
typename
common
<
SystemAccount
>::
eosio_parameters
;
using
eosio_parameters_singleton
=
typename
common
<
SystemAccount
>::
eosio_parameters
_singleton
;
using
global_state_singleton
=
typename
common
<
SystemAccount
>::
global_state
_singleton
;
static
constexpr
uint32_t
max_unstake_requests
=
10
;
static
constexpr
uint32_t
unstake_pay_period
=
7
*
24
*
3600
;
// one per week
...
...
@@ -51,7 +51,7 @@ namespace eosiosystem {
uint64_t
primary_key
()
const
{
return
owner
;
}
uint128_t
by_votes
()
const
{
return
total_votes
;
}
bool
active
()
const
{
return
packed_key
.
size
()
==
4
+
33
/*serialized key size*/
;
}
bool
active
()
const
{
return
packed_key
.
size
()
==
sizeof
(
public_key
)
;
}
EOSLIB_SERIALIZE
(
producer_info
,
(
owner
)(
total_votes
)(
prefs
)(
packed_key
)
)
};
...
...
@@ -81,12 +81,12 @@ namespace eosiosystem {
typedef
eosio
::
multi_index
<
N
(
voters
),
voter_info
>
voters_table
;
ACTION
(
SystemAccount
,
reg
ister_
producer
)
{
ACTION
(
SystemAccount
,
regproducer
)
{
account_name
producer
;
bytes
producer_key
;
eosio_parameters
prefs
;
EOSLIB_SERIALIZE
(
reg
ister_
producer
,
(
producer
)(
producer_key
)(
prefs
)
)
EOSLIB_SERIALIZE
(
regproducer
,
(
producer
)(
producer_key
)(
prefs
)
)
};
/**
...
...
@@ -97,13 +97,17 @@ namespace eosiosystem {
* @pre authority of producer to register
*
*/
static
void
on
(
const
reg
ister_
producer
&
reg
)
{
static
void
on
(
const
regproducer
&
reg
)
{
require_auth
(
reg
.
producer
);
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
const
auto
*
existing
=
producers_tbl
.
find
(
reg
.
producer
);
eosio_assert
(
!
existing
,
"producer already registered"
);
const
auto
*
prod
=
producers_tbl
.
find
(
reg
.
producer
);
if
(
prod
)
{
producers_tbl
.
update
(
*
prod
,
reg
.
producer
,
[
&
](
producer_info
&
info
){
info
.
prefs
=
reg
.
prefs
;
});
}
else
{
producers_tbl
.
emplace
(
reg
.
producer
,
[
&
](
producer_info
&
info
){
info
.
owner
=
reg
.
producer
;
info
.
total_votes
=
0
;
...
...
@@ -111,25 +115,6 @@ namespace eosiosystem {
info
.
packed_key
=
reg
.
producer_key
;
});
}
ACTION
(
SystemAccount
,
change_eosio_parameters
)
{
account_name
producer
;
bytes
producer_key
;
eosio_parameters
prefs
;
EOSLIB_SERIALIZE
(
register_producer
,
(
producer
)(
producer_key
)(
prefs
)
)
};
static
void
on
(
const
change_eosio_parameters
&
change
)
{
require_auth
(
change
.
producer
);
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
const
auto
*
prod
=
producers_tbl
.
find
(
change
.
producer
);
eosio_assert
(
bool
(
prod
),
"producer is not registered"
);
producers_tbl
.
update
(
*
prod
,
change
.
producer
,
[
&
](
producer_info
&
info
){
info
.
prefs
=
change
.
prefs
;
});
}
ACTION
(
SystemAccount
,
stakevote
)
{
...
...
@@ -208,8 +193,9 @@ namespace eosiosystem {
if
(
it
->
active
()
)
{
schedule
.
producers
.
emplace_back
();
schedule
.
producers
.
back
().
producer_name
=
it
->
owner
;
eosio_assert
(
sizeof
(
schedule
.
producers
)
==
it
->
packed_key
.
size
(),
"size mismatch"
);
std
::
copy
(
it
->
packed_key
.
begin
(),
it
->
packed_key
.
end
(),
schedule
.
producers
.
back
().
block_signing_key
.
begin
()
);
schedule
.
producers
);
target_block_size
[
n
]
=
it
->
prefs
.
target_block_size
;
max_block_size
[
n
]
=
it
->
prefs
.
max_block_size
;
...
...
@@ -243,7 +229,7 @@ namespace eosiosystem {
set_active_producers
(
packed_schedule
.
data
(),
packed_schedule
.
size
()
);
size_t
median
=
n
/
2
;
auto
parameters
=
eosio_parameters
_singleton
::
get
();
auto
parameters
=
global_state
_singleton
::
get
();
parameters
.
target_block_size
=
target_block_size
[
median
];
parameters
.
max_block_size
=
max_block_size
[
median
];
...
...
@@ -267,7 +253,7 @@ namespace eosiosystem {
set_blockchain_parameters
(
&
parameters
);
eosio_parameters
_singleton
::
set
(
parameters
);
global_state
_singleton
::
set
(
parameters
);
}
static
void
on
(
const
stakevote
&
sv
)
{
...
...
contracts/eosiolib/privileged.hpp
浏览文件 @
106a2997
#pragma once
#include "privileged.h"
#include "serialize.hpp"
#include "types.h"
namespace
eosio
{
struct
blockchain_parameters
:
::
blockchain_parameters
{
...
...
@@ -14,14 +15,14 @@ namespace eosio {
struct
producer_key
{
account_name
producer_name
;
std
::
array
<
char
,
4
+
33
>
block_signing_key
;
public_key
block_signing_key
;
EOSLIB_SERIALIZE
(
producer_key
,
(
producer_name
)(
block_signing_key
)
)
};
struct
producer_schedule
{
uint32_t
version
=
0
;
///< sequentially incrementing version number
vector
<
producer_key
>
producers
;
std
::
vector
<
producer_key
>
producers
;
EOSLIB_SERIALIZE
(
producer_schedule
,
(
version
)(
producers
)
)
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录