Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
7237920d
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,发现更多精彩内容 >>
未验证
提交
7237920d
编写于
2月 13, 2018
作者:
W
wanderingbort
提交者:
GitHub
2月 13, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1374 from EOSIO/system
eosio.system del net bandwidth impl
上级
6b14e60f
9bb757ac
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
33 deletion
+50
-33
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+25
-13
contracts/eosiolib/multi_index.hpp
contracts/eosiolib/multi_index.hpp
+0
-1
contracts/eosiolib/privileged.h
contracts/eosiolib/privileged.h
+24
-0
contracts/eosiolib/system.h
contracts/eosiolib/system.h
+0
-19
contracts/test.system/test.system.cpp
contracts/test.system/test.system.cpp
+1
-0
未找到文件。
contracts/eosio.system/eosio.system.hpp
浏览文件 @
7237920d
...
...
@@ -12,6 +12,7 @@
#include <eosiolib/datastream.hpp>
#include <eosiolib/serialize.hpp>
#include <eosiolib/multi_index.hpp>
#include <eosiolib/privileged.h>
namespace
eosiosystem
{
...
...
@@ -21,12 +22,15 @@ namespace eosiosystem {
static
const
account_name
system_account
=
SystemAccount
;
typedef
eosio
::
generic_currency
<
eosio
::
token
<
system_account
,
S
(
4
,
EOS
)
>
>
currency
;
struct
total_
bandwidth
{
struct
total_
resources
{
account_name
owner
;
typename
currency
::
token_type
total_net_weight
;
typename
currency
::
token_type
total_cpu_weight
;
uint32_t
total_ram
=
0
;
uint64_t
primary_key
()
const
{
return
owner
;
}
EOSLIB_SERIALIZE
(
total_resources
,
(
owner
)(
total_net_weight
)(
total_cpu_weight
)(
total_ram
)
);
};
...
...
@@ -50,10 +54,15 @@ namespace eosiosystem {
uint64_t
primary_key
()
const
{
return
to
;
}
EOSLIB_SERIALIZE
(
delegated_bandwidth
,
(
from
)(
to
)(
net_weight
)(
cpu_weight
)
(
start_pending_net_withdraw
)(
pending_net_withdraw
)(
deferred_net_withdraw_handler
)
(
start_pending_cpu_withdraw
)(
pending_cpu_withdraw
)(
deferred_cpu_withdraw_handler
)
);
};
typedef
eosio
::
multi_index
<
N
(
totalband
),
total_
bandwidth
>
total_bandwidth
_index_type
;
typedef
eosio
::
multi_index
<
N
(
totalband
),
total_
resources
>
total_resources
_index_type
;
typedef
eosio
::
multi_index
<
N
(
delband
),
delegated_bandwidth
>
del_bandwidth_index_type
;
...
...
@@ -80,7 +89,7 @@ namespace eosiosystem {
typename
currency
::
token_type
stake_quantity
;
EOSLIB_SERIALIZE
(
delnetbw
,
(
delegator
)(
receiver
)(
stake_quantity
)
)
EOSLIB_SERIALIZE
(
delnetbw
,
(
from
)(
receiver
)(
stake_quantity
)
)
};
ACTION
(
SystemAccount
,
undelnetbw
)
{
...
...
@@ -105,14 +114,15 @@ namespace eosiosystem {
require_auth
(
del
.
from
);
del_bandwidth_index_type
del_index
(
SystemAccount
,
del
.
from
);
total_bandwidth_index_type
total_index
(
SystemAccount
,
del
.
to
);
// require_account( receiver );
total_resources_index_type
total_index
(
SystemAccount
,
del
.
receiver
);
//eosio_assert( is_account( del.receiver ), "can only delegate resources to an existing account" );
auto
itr
=
del_index
.
find
(
del
.
to
);
if
(
itr
==
del_index
.
end
()
)
{
auto
itr
=
del_index
.
find
(
del
.
receiver
);
if
(
itr
!=
nullptr
)
{
del_index
.
emplace
(
del
.
from
,
[
&
](
auto
&
dbo
){
dbo
.
from
=
del
.
from
;
dbo
.
to
=
del
.
to
;
dbo
.
to
=
del
.
receiver
;
dbo
.
net_weight
=
del
.
stake_quantity
;
});
}
...
...
@@ -122,10 +132,10 @@ namespace eosiosystem {
});
}
auto
tot_itr
=
total_index
.
find
(
del
.
to
);
if
(
tot_itr
==
total_index
.
end
()
)
{
total_index
.
emplace
(
del
.
from
,
[
&
](
auto
&
tot
)
{
tot
.
owner
=
del
.
to
;
auto
tot_itr
=
total_index
.
find
(
del
.
receiver
);
if
(
tot_itr
==
nullptr
)
{
tot
_itr
=
&
tot
al_index
.
emplace
(
del
.
from
,
[
&
](
auto
&
tot
)
{
tot
.
owner
=
del
.
receiver
;
tot
.
total_net_weight
+=
del
.
stake_quantity
;
});
}
else
{
...
...
@@ -134,6 +144,8 @@ namespace eosiosystem {
});
}
set_resource_limits
(
tot_itr
->
owner
,
tot_itr
->
total_ram
,
tot_itr
->
total_net_weight
.
quantity
,
tot_itr
->
total_cpu_weight
.
quantity
,
0
);
currency
::
inline_transfer
(
del
.
from
,
SystemAccount
,
del
.
stake_quantity
,
"stake bandwidth"
);
}
// delnetbw
...
...
@@ -150,7 +162,7 @@ namespace eosiosystem {
static
void
apply
(
account_name
code
,
action_name
act
)
{
if
(
!
eosio
::
dispatch
<
contract
,
regproducer
,
regproxy
,
nonce
>
(
code
,
act
)
)
{
if
(
!
eosio
::
dispatch
<
contract
,
regproducer
,
regproxy
,
delnetbw
,
nonce
>
(
code
,
act
)
)
{
if
(
!
eosio
::
dispatch
<
currency
,
typename
currency
::
transfer
,
typename
currency
::
issue
>
(
code
,
act
)
)
{
eosio
::
print
(
"Unexpected action: "
,
eosio
::
name
(
act
),
"
\n
"
);
eosio_assert
(
false
,
"received unexpected action"
);
...
...
contracts/eosiolib/multi_index.hpp
浏览文件 @
7237920d
...
...
@@ -436,7 +436,6 @@ class multi_index
auto
secondary_keys
=
boost
::
hana
::
transform
(
_indicies
,
[
&
](
auto
&
idx
)
{
return
idx
.
extract_secondary_key
(
obj
);
});
boost
::
hana
::
at_c
<
0
>
(
secondary_keys
);
auto
mutableobj
=
const_cast
<
T
&>
(
obj
);
updater
(
mutableobj
);
...
...
contracts/eosiolib/privileged.h
0 → 100644
浏览文件 @
7237920d
#pragma once
extern
"C"
{
/**
* @defgroup privilegedapi Privileged API
* @ingroup systemapi
* @brief Defines an API for accessing configuration of the chain that can only be done by privileged accounts
*/
/**
* @defgroup privilegedcapi Privileged C API
* @ingroup privilegedapi
* @brief Define C Privileged API
*
* @{
*/
void
set_resource_limits
(
account_name
account
,
int64_t
ram_bytes
,
int64_t
net_weight
,
int64_t
cpu_weight
,
int64_t
ignored
);
void
set_active_producers
(
char
*
producer_data
,
size_t
producer_data_size
);
///@ } privilegedcapi
}
contracts/eosiolib/system.h
浏览文件 @
7237920d
...
...
@@ -39,25 +39,6 @@ extern "C" {
time
now
();
///@ } systemcapi
/**
* @defgroup privilegedapi Privileged API
* @ingroup systemapi
* @brief Defines an API for accessing configuration of the chain that can only be done by privileged accounts
*/
/**
* @defgroup privilegedcapi Privileged C API
* @ingroup privilegedapi
* @brief Define C Privileged API
*
* @{
*/
void
set_resource_limits
(
account_name
account
,
int64_t
ram_bytes
,
int64_t
net_weight
,
int64_t
cpu_weight
,
int64_t
ignored
);
void
set_active_producers
(
char
*
producer_data
,
size_t
producer_data_size
);
///@ } privilegedcapi
}
contracts/test.system/test.system.cpp
浏览文件 @
7237920d
...
...
@@ -7,6 +7,7 @@
#include <eosiolib/types.hpp>
#include <eosiolib/serialize.hpp>
#include <eosiolib/system.h>
#include <eosiolib/privileged.h>
using
namespace
eosio
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录