Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
831cf175
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,发现更多精彩内容 >>
提交
831cf175
编写于
4月 29, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean up producer reg and producer info table
上级
540f2558
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
86 addition
and
131 deletion
+86
-131
contracts/eosio.system/delegate_bandwidth.cpp
contracts/eosio.system/delegate_bandwidth.cpp
+19
-3
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+15
-5
contracts/eosio.system/eosio.system.cpp
contracts/eosio.system/eosio.system.cpp
+1
-0
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+8
-7
contracts/eosio.system/voting.cpp
contracts/eosio.system/voting.cpp
+17
-43
contracts/eosio.system/voting.hpp
contracts/eosio.system/voting.hpp
+2
-56
contracts/eosiolib/fixed_key.hpp
contracts/eosiolib/fixed_key.hpp
+1
-1
contracts/eosiolib/public_key.hpp
contracts/eosiolib/public_key.hpp
+6
-0
libraries/chain/abi_serializer.cpp
libraries/chain/abi_serializer.cpp
+0
-1
libraries/chain/include/eosio/chain/abi_serializer.hpp
libraries/chain/include/eosio/chain/abi_serializer.hpp
+0
-1
libraries/chain/resource_limits.cpp
libraries/chain/resource_limits.cpp
+9
-2
programs/cleos/main.cpp
programs/cleos/main.cpp
+8
-12
未找到文件。
contracts/eosio.system/delegate_bandwidth.cpp
浏览文件 @
831cf175
...
...
@@ -98,7 +98,9 @@ namespace eosiosystem {
auto
parameters
=
gs
.
exists
()
?
gs
.
get
()
:
get_default_parameters
();
const
eosio
::
asset
token_supply
=
eosio
::
token
(
N
(
eosio
.
token
)).
get_supply
(
eosio
::
symbol_type
(
system_token_symbol
).
name
());
print
(
"token supply: "
,
token_supply
,
" "
);
print
(
" token supply: "
,
token_supply
,
"
\n
"
);
print
(
" max storage size: "
,
parameters
.
max_storage_size
,
"
\n
"
);
print
(
" total reserved: "
,
parameters
.
total_storage_bytes_reserved
,
"
\n
"
);
//make sure that there is no posibility of overflow here
int64_t
storage_bytes_estimated
=
int64_t
(
parameters
.
max_storage_size
-
parameters
.
total_storage_bytes_reserved
)
...
...
@@ -112,7 +114,7 @@ namespace eosiosystem {
eosio_assert
(
0
<
storage_bytes
,
"stake is too small to increase storage even by 1 byte"
);
parameters
.
total_storage_bytes_reserved
+=
uint64_t
(
storage_bytes
);
print
(
"
\n
total storage stake: "
,
parameters
.
total_storage_stake
);
print
(
"
\n
total storage stake: "
,
parameters
.
total_storage_stake
,
"
\n
"
);
parameters
.
total_storage_stake
+=
stake_storage_quantity
;
gs
.
set
(
parameters
,
_self
);
}
...
...
@@ -168,6 +170,20 @@ namespace eosiosystem {
}
// delegatebw
void
system_contract
::
setparams
(
uint64_t
max_storage_size
,
uint32_t
storage_reserve_ratio
)
{
require_auth
(
_self
);
eosio_assert
(
storage_reserve_ratio
>
0
,
"invalid reserve ratio"
);
global_state_singleton
gs
(
_self
,
_self
);
auto
parameters
=
gs
.
exists
()
?
gs
.
get
()
:
get_default_parameters
();
eosio_assert
(
max_storage_size
>
parameters
.
total_storage_bytes_reserved
,
"attempt to set max below reserved"
);
parameters
.
max_storage_size
=
max_storage_size
;
parameters
.
storage_reserve_ratio
=
storage_reserve_ratio
;
gs
.
set
(
parameters
,
_self
);
}
void
system_contract
::
undelegatebw
(
const
account_name
from
,
const
account_name
receiver
,
const
asset
unstake_net_quantity
,
const
asset
unstake_cpu_quantity
,
...
...
@@ -218,7 +234,7 @@ namespace eosiosystem {
tot
.
storage_bytes
-=
unstake_storage_bytes
;
});
//set_resource_limits( totals.owner, totals.storage_bytes, totals.net_weight.quantity, totals.cpu_weight.quantity
);
set_resource_limits
(
totals
.
owner
,
totals
.
storage_bytes
,
totals
.
net_weight
.
amount
,
totals
.
cpu_weight
.
amount
);
refunds_table
refunds_tbl
(
_self
,
from
);
//create refund request
...
...
contracts/eosio.system/eosio.system.abi
浏览文件 @
831cf175
...
...
@@ -140,18 +140,17 @@
"fields": [
{"name":"owner", "type":"account_name"},
{"name":"total_votes", "type":"uint128"},
{"name":"prefs", "type":"eosio_parameters"},
{"name":"packed_key", "type":"uint8[]"},
{"name":"packed_key", "type":"public_key"},
{"name":"per_block_payments", "type":"uint64"},
{"name":"last_claim_time", "type":"
uint32
"}
{"name":"last_claim_time", "type":"
time
"}
]
},{
"name": "regproducer",
"base": "",
"fields": [
{"name":"producer", "type":"account_name"},
{"name":"producer_key", "type":"
bytes
"},
{"name":"
prefs", "type":"eosio_parameters
"}
{"name":"producer_key", "type":"
public_key
"},
{"name":"
url", "type":"string
"}
]
},{
"name": "unregprod",
...
...
@@ -159,6 +158,13 @@
"fields": [
{"name":"producer", "type":"account_name"}
]
},{
"name": "setparams",
"base": "",
"fields": [
{"name":"max_ram_size", "type":"uint64"}
{"name":"ram_reserve_ratio", "type":"uint32"}
]
},{
"name": "regproxy",
"base": "",
...
...
@@ -227,6 +233,10 @@
"name": "regproducer",
"type": "regproducer",
"ricardian_contract": ""
},{
"name": "setparams",
"type": "setparams",
"ricardian_contract": ""
},{
"name": "unregprod",
"type": "unregprod",
...
...
contracts/eosio.system/eosio.system.cpp
浏览文件 @
831cf175
...
...
@@ -6,6 +6,7 @@
#include "voting.cpp"
EOSIO_ABI
(
eosiosystem
::
system_contract
,
(
setparams
)
// delegate_bandwith.cpp
(
delegatebw
)(
undelegatebw
)(
refund
)
(
regproxy
)
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
831cf175
...
...
@@ -35,9 +35,9 @@ namespace eosiosystem {
};
struct
eosio_parameters
:
eosio
::
blockchain_parameters
{
uint64_t
max_storage_size
=
10
*
1024
*
1024
;
uint64_t
max_storage_size
=
10
24
*
1024
*
1024
;
uint32_t
percent_of_max_inflation_rate
=
0
;
uint32_t
storage_reserve_ratio
=
1
000
;
// ratio * 1000
uint32_t
storage_reserve_ratio
=
2
000
;
// ratio * 1000
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE_DERIVED
(
eosio_parameters
,
eosio
::
blockchain_parameters
,
(
max_storage_size
)(
percent_of_max_inflation_rate
)(
storage_reserve_ratio
)
)
...
...
@@ -62,8 +62,7 @@ namespace eosiosystem {
struct
producer_info
{
account_name
owner
;
uint128_t
total_votes
=
0
;
eosio_parameters
prefs
;
eosio
::
bytes
packed_key
;
/// a packed public key object
eosio
::
public_key
producer_key
;
/// a packed public key object
eosio
::
asset
per_block_payments
;
time
last_rewards_claim
=
0
;
time
time_became_active
=
0
;
...
...
@@ -71,10 +70,10 @@ namespace eosiosystem {
uint64_t
primary_key
()
const
{
return
owner
;
}
uint128_t
by_votes
()
const
{
return
total_votes
;
}
bool
active
()
const
{
return
0
<
packed_key
.
size
();
}
bool
active
()
const
{
return
producer_key
!=
public_key
();
}
// explicit serialization macro is not necessary, used here only to improve compilation time
EOSLIB_SERIALIZE
(
producer_info
,
(
owner
)(
total_votes
)(
pr
efs
)(
packed
_key
)
EOSLIB_SERIALIZE
(
producer_info
,
(
owner
)(
total_votes
)(
pr
oducer
_key
)
(
per_block_payments
)(
last_rewards_claim
)
(
time_became_active
)(
last_produced_block_time
)
)
};
...
...
@@ -109,10 +108,12 @@ namespace eosiosystem {
// functions defined in voting.cpp
void
regproducer
(
const
account_name
producer
,
const
bytes
&
producer_key
,
const
eosio_parameters
&
prefs
);
void
regproducer
(
const
account_name
producer
,
const
public_key
&
producer_key
,
const
std
::
string
&
url
);
void
unregprod
(
const
account_name
producer
);
void
setparams
(
uint64_t
max_storage_size
,
uint32_t
storage_reserve_ratio
);
void
voteproducer
(
const
account_name
voter
,
const
account_name
proxy
,
const
std
::
vector
<
account_name
>&
producers
);
...
...
contracts/eosio.system/voting.cpp
浏览文件 @
831cf175
...
...
@@ -59,27 +59,25 @@ namespace eosiosystem {
* @pre authority of producer to register
*
*/
void
system_contract
::
regproducer
(
const
account_name
producer
,
const
bytes
&
packed_producer_key
,
const
eosio_parameters
&
prefs
)
{
void
system_contract
::
regproducer
(
const
account_name
producer
,
const
public_key
&
producer_key
,
const
std
::
string
&
url
)
{
//, const eosio_parameters& prefs ) {
eosio_assert
(
url
.
size
()
<
1024
,
"url too long"
);
//eosio::print("produce_key: ", producer_key.size(), ", sizeof(public_key): ", sizeof(public_key), "\n");
require_auth
(
producer
);
producers_table
producers_tbl
(
_self
,
_self
);
auto
prod
=
producers_tbl
.
find
(
producer
);
//check that we can unpack producer key
public_key
producer_key
=
eosio
::
unpack
<
public_key
>
(
packed_producer_key
);
if
(
prod
!=
producers_tbl
.
end
()
)
{
producers_tbl
.
modify
(
prod
,
producer
,
[
&
](
producer_info
&
info
){
info
.
prefs
=
prefs
;
info
.
packed_key
=
eosio
::
pack
<
public_key
>
(
producer_key
);
});
if
(
producer_key
!=
prod
->
producer_key
)
{
producers_tbl
.
modify
(
prod
,
producer
,
[
&
](
producer_info
&
info
){
info
.
producer_key
=
producer_key
;
});
}
}
else
{
producers_tbl
.
emplace
(
producer
,
[
&
](
producer_info
&
info
){
info
.
owner
=
producer
;
info
.
total_votes
=
0
;
info
.
prefs
=
prefs
;
info
.
packed_key
=
eosio
::
pack
<
public_key
>
(
producer_key
);
info
.
producer_key
=
producer_key
;
});
}
}
...
...
@@ -92,7 +90,7 @@ namespace eosiosystem {
eosio_assert
(
prod
!=
producers_tbl
.
end
(),
"producer not found"
);
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
producer_info
&
info
){
info
.
p
acked_key
.
clear
();
info
.
p
roducer_key
=
public_key
();
});
}
...
...
@@ -205,6 +203,7 @@ namespace eosiosystem {
producers_table
producers_tbl
(
_self
,
_self
);
auto
idx
=
producers_tbl
.
template
get_index
<
N
(
prototalvote
)>();
/*
std::array<uint64_t, 21> max_block_net_usage;
std::array<uint32_t, 21> target_block_net_usage_pct;
std::array<uint32_t, 21> base_per_transaction_net_usage;
...
...
@@ -233,6 +232,7 @@ namespace eosiosystem {
std::array<uint32_t, 21> max_storage_size;
std::array<uint32_t, 21> percent_of_max_inflation_rate;
std::array<uint32_t, 21> storage_reserve_ratio;
*/
eosio
::
producer_schedule
schedule
;
schedule
.
producers
.
reserve
(
21
);
...
...
@@ -242,9 +242,10 @@ namespace eosiosystem {
schedule
.
producers
.
emplace_back
();
schedule
.
producers
.
back
().
producer_name
=
it
->
owner
;
//eosio_assert( sizeof(schedule.producers.back().block_signing_key) == it->packed_key.size(), "size mismatch" );
schedule
.
producers
.
back
().
block_signing_key
=
eosio
::
unpack
<
public_key
>
(
it
->
packed_key
);
schedule
.
producers
.
back
().
block_signing_key
=
it
->
producer_key
;
//std::copy( it->packed_key.begin(), it->packed_key.end(), schedule.producers.back().block_signing_key.data.data() );
/*
max_block_net_usage[n] = it->prefs.max_block_net_usage;
target_block_net_usage_pct[n] = it->prefs.target_block_net_usage_pct;
max_transaction_net_usage[n] = it->prefs.max_transaction_net_usage;
...
...
@@ -273,51 +274,23 @@ namespace eosiosystem {
max_storage_size[n] = it->prefs.max_storage_size;
storage_reserve_ratio[n] = it->prefs.storage_reserve_ratio;
percent_of_max_inflation_rate[n] = it->prefs.percent_of_max_inflation_rate;
*/
++
n
;
}
}
if
(
n
==
0
)
{
//no active producers with votes > 0
return
;
}
if
(
1
<
n
)
{
std
::
sort
(
max_block_net_usage
.
begin
(),
max_block_net_usage
.
begin
()
+
n
);
std
::
sort
(
target_block_net_usage_pct
.
begin
(),
target_block_net_usage_pct
.
begin
()
+
n
);
std
::
sort
(
max_transaction_net_usage
.
begin
(),
max_transaction_net_usage
.
begin
()
+
n
);
std
::
sort
(
base_per_transaction_net_usage
.
begin
(),
base_per_transaction_net_usage
.
begin
()
+
n
);
std
::
sort
(
context_free_discount_net_usage_num
.
begin
(),
context_free_discount_net_usage_num
.
begin
()
+
n
);
std
::
sort
(
context_free_discount_net_usage_den
.
begin
(),
context_free_discount_net_usage_den
.
begin
()
+
n
);
std
::
sort
(
max_block_cpu_usage
.
begin
(),
max_block_cpu_usage
.
begin
()
+
n
);
std
::
sort
(
target_block_cpu_usage_pct
.
begin
(),
target_block_cpu_usage_pct
.
begin
()
+
n
);
std
::
sort
(
max_transaction_cpu_usage
.
begin
(),
max_transaction_cpu_usage
.
begin
()
+
n
);
std
::
sort
(
base_per_transaction_cpu_usage
.
begin
(),
base_per_transaction_cpu_usage
.
begin
()
+
n
);
std
::
sort
(
base_per_action_cpu_usage
.
begin
(),
base_per_action_cpu_usage
.
begin
()
+
n
);
std
::
sort
(
base_setcode_cpu_usage
.
begin
(),
base_setcode_cpu_usage
.
begin
()
+
n
);
std
::
sort
(
per_signature_cpu_usage
.
begin
(),
per_signature_cpu_usage
.
begin
()
+
n
);
std
::
sort
(
context_free_discount_cpu_usage_num
.
begin
(),
context_free_discount_cpu_usage_num
.
begin
()
+
n
);
std
::
sort
(
context_free_discount_cpu_usage_den
.
begin
(),
context_free_discount_cpu_usage_den
.
begin
()
+
n
);
std
::
sort
(
max_transaction_lifetime
.
begin
(),
max_transaction_lifetime
.
begin
()
+
n
);
std
::
sort
(
deferred_trx_expiration_window
.
begin
(),
deferred_trx_expiration_window
.
begin
()
+
n
);
std
::
sort
(
max_transaction_delay
.
begin
(),
max_transaction_delay
.
begin
()
+
n
);
std
::
sort
(
max_inline_action_size
.
begin
(),
max_inline_action_size
.
begin
()
+
n
);
std
::
sort
(
max_inline_action_depth
.
begin
(),
max_inline_action_depth
.
begin
()
+
n
);
std
::
sort
(
max_authority_depth
.
begin
(),
max_authority_depth
.
begin
()
+
n
);
std
::
sort
(
max_generated_transaction_count
.
begin
(),
max_generated_transaction_count
.
begin
()
+
n
);
std
::
sort
(
max_storage_size
.
begin
(),
max_storage_size
.
begin
()
+
n
);
std
::
sort
(
storage_reserve_ratio
.
begin
(),
storage_reserve_ratio
.
begin
()
+
n
);
std
::
sort
(
percent_of_max_inflation_rate
.
begin
(),
percent_of_max_inflation_rate
.
begin
()
+
n
);
}
// should use producer_schedule_type from libraries/chain/include/eosio/chain/producer_schedule.hpp
bytes
packed_schedule
=
pack
(
schedule
);
set_active_producers
(
packed_schedule
.
data
(),
packed_schedule
.
size
()
);
size_t
median
=
n
/
2
;
//
size_t median = n/2;
global_state_singleton
gs
(
_self
,
_self
);
auto
parameters
=
gs
.
exists
()
?
gs
.
get
()
:
get_default_parameters
();
/*
parameters.max_block_net_usage = max_block_net_usage[median];
parameters.target_block_net_usage_pct = target_block_net_usage_pct[median];
parameters.max_transaction_net_usage = max_transaction_net_usage[median];
...
...
@@ -346,6 +319,7 @@ namespace eosiosystem {
parameters.max_storage_size = max_storage_size[median];
parameters.storage_reserve_ratio = storage_reserve_ratio[median];
parameters.percent_of_max_inflation_rate = percent_of_max_inflation_rate[median];
*/
// not voted on
parameters
.
first_block_time_in_cycle
=
cycle_time
;
...
...
contracts/eosio.system/voting.hpp
浏览文件 @
831cf175
...
...
@@ -45,7 +45,7 @@ namespace eosiosystem {
struct
producer_info
{
account_name
owner
;
uint128_t
total_votes
=
0
;
eosio_parameters
prefs
;
//
eosio_parameters prefs;
eosio
::
bytes
packed_key
;
/// a packed public key object
system_token_type
per_block_payments
;
time
last_rewards_claim
=
0
;
...
...
@@ -56,7 +56,7 @@ namespace eosiosystem {
uint128_t
by_votes
()
const
{
return
total_votes
;
}
bool
active
()
const
{
return
packed_key
.
size
()
==
sizeof
(
public_key
);
}
EOSLIB_SERIALIZE
(
producer_info
,
(
owner
)(
total_votes
)(
p
refs
)(
p
acked_key
)
EOSLIB_SERIALIZE
(
producer_info
,
(
owner
)(
total_votes
)(
packed_key
)
(
per_block_payments
)(
last_rewards_claim
)
(
time_became_active
)(
last_produced_block_time
)
)
};
...
...
@@ -86,60 +86,6 @@ namespace eosiosystem {
typedef
eosio
::
multi_index
<
N
(
voters
),
voter_info
>
voters_table
;
ACTION
(
SystemAccount
,
regproducer
)
{
account_name
producer
;
bytes
producer_key
;
eosio_parameters
prefs
;
EOSLIB_SERIALIZE
(
regproducer
,
(
producer
)(
producer_key
)(
prefs
)
)
};
/**
* This method will create a producer_config and producer_info object for 'producer'
*
* @pre producer is not already registered
* @pre producer to register is an account
* @pre authority of producer to register
*
*/
static
void
on
(
const
regproducer
&
reg
)
{
require_auth
(
reg
.
producer
);
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
auto
prod
=
producers_tbl
.
find
(
reg
.
producer
);
if
(
prod
!=
producers_tbl
.
end
()
)
{
producers_tbl
.
modify
(
prod
,
reg
.
producer
,
[
&
](
producer_info
&
info
){
info
.
prefs
=
reg
.
prefs
;
info
.
packed_key
=
reg
.
producer_key
;
});
}
else
{
producers_tbl
.
emplace
(
reg
.
producer
,
[
&
](
producer_info
&
info
){
info
.
owner
=
reg
.
producer
;
info
.
total_votes
=
0
;
info
.
prefs
=
reg
.
prefs
;
info
.
packed_key
=
reg
.
producer_key
;
});
}
}
ACTION
(
SystemAccount
,
unregprod
)
{
account_name
producer
;
EOSLIB_SERIALIZE
(
unregprod
,
(
producer
)
)
};
static
void
on
(
const
unregprod
&
unreg
)
{
require_auth
(
unreg
.
producer
);
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
auto
prod
=
producers_tbl
.
find
(
unreg
.
producer
);
eosio_assert
(
prod
!=
producers_tbl
.
end
(),
"producer not found"
);
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
producer_info
&
info
){
info
.
packed_key
.
clear
();
});
}
static
void
increase_voting_power
(
account_name
acnt
,
system_token_type
amount
)
{
voters_table
voters_tbl
(
SystemAccount
,
SystemAccount
);
...
...
contracts/eosiolib/fixed_key.hpp
浏览文件 @
831cf175
...
...
@@ -203,7 +203,7 @@ namespace eosio {
* @return if c1 > c2, return true, otherwise false
*/
template
<
size_t
Size
>
bool
operator
>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>
&
c2
)
{
bool
operator
>
(
const
fixed_key
<
Size
>
&
c1
,
const
fixed_key
<
Size
>&
c2
)
{
return
c1
.
_data
>
c2
.
_data
;
}
...
...
contracts/eosiolib/public_key.hpp
浏览文件 @
831cf175
...
...
@@ -7,6 +7,12 @@ namespace eosio {
unsigned_int
type
;
std
::
array
<
char
,
33
>
data
;
friend
bool
operator
==
(
const
public_key
&
a
,
const
public_key
&
b
)
{
return
std
::
tie
(
a
.
type
,
a
.
data
)
==
std
::
tie
(
b
.
type
,
b
.
data
);
}
friend
bool
operator
!=
(
const
public_key
&
a
,
const
public_key
&
b
)
{
return
std
::
tie
(
a
.
type
,
a
.
data
)
==
std
::
tie
(
b
.
type
,
b
.
data
);
}
EOSLIB_SERIALIZE
(
public_key
,
(
type
)(
data
)
)
};
}
libraries/chain/abi_serializer.cpp
浏览文件 @
831cf175
...
...
@@ -317,7 +317,6 @@ namespace eosio { namespace chain {
uint32_t
i
=
0
;
if
(
va
.
size
()
>
0
)
{
for
(
const
auto
&
field
:
st
.
fields
)
{
idump
((
field
.
type
)(
va
[
i
])(
i
));
if
(
va
.
size
()
>
i
)
variant_to_binary
(
field
.
type
,
va
[
i
],
ds
);
else
...
...
libraries/chain/include/eosio/chain/abi_serializer.hpp
浏览文件 @
831cf175
...
...
@@ -390,7 +390,6 @@ namespace impl {
template
<
typename
Resolver
>
static
void
extract
(
const
variant
&
v
,
packed_transaction
&
ptrx
,
Resolver
resolver
)
{
const
variant_object
&
vo
=
v
.
get_object
();
wdump
((
vo
));
EOS_ASSERT
(
vo
.
contains
(
"signatures"
),
packed_transaction_type_exception
,
"Missing signatures"
);
EOS_ASSERT
(
vo
.
contains
(
"compression"
),
packed_transaction_type_exception
,
"Missing compression"
);
from_variant
(
vo
[
"signatures"
],
ptrx
.
signatures
);
...
...
libraries/chain/resource_limits.cpp
浏览文件 @
831cf175
...
...
@@ -296,9 +296,12 @@ int64_t resource_limits_manager::get_account_cpu_limit( const account_name& name
return
-
1
;
}
auto
total_cpu_weight
=
state
.
total_cpu_weight
;
if
(
total_cpu_weight
==
0
)
total_cpu_weight
=
1
;
uint128_t
consumed_ex
=
(
uint128_t
)
usage
.
cpu_usage
.
consumed
*
(
uint128_t
)
config
::
rate_limiting_precision
;
uint128_t
virtual_capacity_ex
=
(
uint128_t
)
state
.
virtual_cpu_limit
*
(
uint128_t
)
config
::
rate_limiting_precision
;
uint128_t
usable_capacity_ex
=
(
uint128_t
)(
virtual_capacity_ex
*
limits
.
cpu_weight
)
/
(
uint128_t
)
state
.
total_cpu_weight
;
uint128_t
usable_capacity_ex
=
(
uint128_t
)(
virtual_capacity_ex
*
limits
.
cpu_weight
)
/
(
uint128_t
)
total_cpu_weight
;
if
(
usable_capacity_ex
<
consumed_ex
)
{
return
0
;
...
...
@@ -317,7 +320,11 @@ int64_t resource_limits_manager::get_account_net_limit( const account_name& name
uint128_t
consumed_ex
=
(
uint128_t
)
usage
.
net_usage
.
consumed
*
(
uint128_t
)
config
::
rate_limiting_precision
;
uint128_t
virtual_capacity_ex
=
(
uint128_t
)
state
.
virtual_net_limit
*
(
uint128_t
)
config
::
rate_limiting_precision
;
uint128_t
usable_capacity_ex
=
(
uint128_t
)(
virtual_capacity_ex
*
limits
.
net_weight
)
/
(
uint128_t
)
state
.
total_net_weight
;
auto
total_net_weight
=
state
.
total_net_weight
;
if
(
total_net_weight
==
0
)
total_net_weight
=
1
;
uint128_t
usable_capacity_ex
=
(
uint128_t
)(
virtual_capacity_ex
*
limits
.
net_weight
)
/
(
uint128_t
)
total_net_weight
;
if
(
usable_capacity_ex
<
consumed_ex
)
{
return
0
;
...
...
programs/cleos/main.cpp
浏览文件 @
831cf175
...
...
@@ -403,9 +403,8 @@ chain::action create_action(const vector<permission_level>& authorization, const
fc
::
variant
regproducer_variant
(
const
account_name
&
producer
,
public_key_type
key
,
uint64_t
max_storage_size
,
uint32_t
percent_of_max_inflation_rate
,
uint32_t
storage_reserve_ratio
)
{
string
url
)
{
/*
fc::variant_object params = fc::mutable_variant_object()
("max_block_net_usage", config::default_max_block_net_usage)
("target_block_net_usage_pct", config::default_target_block_net_usage_pct)
...
...
@@ -432,11 +431,12 @@ fc::variant regproducer_variant(const account_name& producer,
("max_storage_size", max_storage_size)
("percent_of_max_inflation_rate", percent_of_max_inflation_rate)
("storage_reserve_ratio", storage_reserve_ratio);
*/
return
fc
::
mutable_variant_object
()
(
"producer"
,
producer
)
(
"producer_key"
,
fc
::
raw
::
pack
(
key
)
)
(
"
prefs"
,
params
);
(
"producer_key"
,
key
)
(
"
url"
,
url
);
}
chain
::
action
create_transfer
(
const
string
&
contract
,
const
name
&
sender
,
const
name
&
recipient
,
asset
amount
,
const
string
&
memo
)
{
...
...
@@ -625,17 +625,13 @@ CLI::callback_t old_host_port = [](CLI::results_t) {
struct
register_producer_subcommand
{
string
producer_str
;
string
producer_key_str
;
uint64_t
max_storage_size
=
10
*
1024
*
1024
;
uint32_t
percent_of_max_inflation_rate
=
0
;
uint32_t
storage_reserve_ratio
=
1000
;
string
url
;
register_producer_subcommand
(
CLI
::
App
*
actionRoot
)
{
auto
register_producer
=
actionRoot
->
add_subcommand
(
"regproducer"
,
localized
(
"Register a new producer"
));
register_producer
->
add_option
(
"account"
,
producer_str
,
localized
(
"The account to register as a producer"
))
->
required
();
register_producer
->
add_option
(
"producer_key"
,
producer_key_str
,
localized
(
"The producer's public key"
))
->
required
();
register_producer
->
add_option
(
"max_storage_size"
,
max_storage_size
,
localized
(
"The max storage size"
),
true
);
register_producer
->
add_option
(
"percent_of_max_inflation_rate"
,
percent_of_max_inflation_rate
,
localized
(
"Percent of max inflation rate"
),
true
);
register_producer
->
add_option
(
"storage_reserve_ratio"
,
storage_reserve_ratio
,
localized
(
"Storage Reserve Ratio"
),
true
);
register_producer
->
add_option
(
"url"
,
url
,
localized
(
"url where info about producer can be found"
),
true
);
add_standard_transaction_options
(
register_producer
);
...
...
@@ -645,7 +641,7 @@ struct register_producer_subcommand {
producer_key
=
public_key_type
(
producer_key_str
);
}
EOS_RETHROW_EXCEPTIONS
(
public_key_type_exception
,
"Invalid producer public key: ${public_key}"
,
(
"public_key"
,
producer_key_str
))
auto
regprod_var
=
regproducer_variant
(
producer_str
,
producer_key
,
max_storage_size
,
percent_of_max_inflation_rate
,
storage_reserve_ratio
);
auto
regprod_var
=
regproducer_variant
(
producer_str
,
producer_key
,
url
);
send_actions
({
create_action
({
permission_level
{
producer_str
,
config
::
active_name
}},
config
::
system_account_name
,
N
(
regproducer
),
regprod_var
)});
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录