Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
84d4b712
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,发现更多精彩内容 >>
提交
84d4b712
编写于
3月 16, 2018
作者:
A
Anton Perkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
compilation fixes after merge
上级
5fc1ee2f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
59 addition
and
62 deletion
+59
-62
contracts/eosio.system/delegate_bandwith.hpp
contracts/eosio.system/delegate_bandwith.hpp
+7
-7
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+6
-9
contracts/eosio.system/voting.hpp
contracts/eosio.system/voting.hpp
+43
-43
contracts/eosiolib/generic_currency.hpp
contracts/eosiolib/generic_currency.hpp
+1
-1
contracts/eosiolib/singleton.hpp
contracts/eosiolib/singleton.hpp
+1
-1
contracts/eosiolib/token.hpp
contracts/eosiolib/token.hpp
+1
-1
未找到文件。
contracts/eosio.system/delegate_bandwith.hpp
浏览文件 @
84d4b712
...
...
@@ -136,7 +136,7 @@ namespace eosiosystem {
del_bandwidth_index_type
del_index
(
SystemAccount
,
del
.
from
);
auto
itr
=
del_index
.
find
(
del
.
receiver
);
if
(
itr
==
nullptr
)
{
if
(
itr
==
del_index
.
end
()
)
{
del_index
.
emplace
(
del
.
from
,
[
&
](
auto
&
dbo
){
dbo
.
from
=
del
.
from
;
dbo
.
to
=
del
.
receiver
;
...
...
@@ -147,7 +147,7 @@ namespace eosiosystem {
});
}
else
{
del_index
.
update
(
*
itr
,
del
.
from
,
[
&
](
auto
&
dbo
){
del_index
.
modify
(
itr
,
del
.
from
,
[
&
](
auto
&
dbo
){
dbo
.
net_weight
+=
del
.
stake_net_quantity
;
dbo
.
cpu_weight
+=
del
.
stake_cpu_quantity
;
dbo
.
storage_stake
+=
del
.
stake_storage_quantity
;
...
...
@@ -157,8 +157,8 @@ namespace eosiosystem {
total_resources_index_type
total_index
(
SystemAccount
,
del
.
receiver
);
auto
tot_itr
=
total_index
.
find
(
del
.
receiver
);
if
(
tot_itr
==
nullptr
)
{
tot_itr
=
&
total_index
.
emplace
(
del
.
from
,
[
&
](
auto
&
tot
)
{
if
(
tot_itr
==
total_index
.
end
()
)
{
tot_itr
=
total_index
.
emplace
(
del
.
from
,
[
&
](
auto
&
tot
)
{
tot
.
owner
=
del
.
receiver
;
tot
.
net_weight
=
del
.
stake_net_quantity
;
tot
.
cpu_weight
=
del
.
stake_cpu_quantity
;
...
...
@@ -166,7 +166,7 @@ namespace eosiosystem {
tot
.
storage_bytes
=
storage_bytes
;
});
}
else
{
total_index
.
update
(
*
tot_itr
,
del
.
from
==
del
.
receiver
?
del
.
from
:
0
,
[
&
](
auto
&
tot
)
{
total_index
.
modify
(
tot_itr
,
del
.
from
==
del
.
receiver
?
del
.
from
:
0
,
[
&
](
auto
&
tot
)
{
tot
.
net_weight
+=
del
.
stake_net_quantity
;
tot
.
cpu_weight
+=
del
.
stake_cpu_quantity
;
tot
.
storage_stake
+=
del
.
stake_storage_quantity
;
...
...
@@ -213,7 +213,7 @@ namespace eosiosystem {
eosio_assert
(
total_refund
.
quantity
>
0
,
"must unstake a positive amount"
);
del_index
.
update
(
dbw
,
del
.
from
,
[
&
](
auto
&
dbo
){
del_index
.
modify
(
dbw
,
del
.
from
,
[
&
](
auto
&
dbo
){
dbo
.
net_weight
-=
del
.
unstake_net_quantity
;
dbo
.
cpu_weight
-=
del
.
unstake_cpu_quantity
;
dbo
.
storage_stake
-=
storage_stake_decrease
;
...
...
@@ -222,7 +222,7 @@ namespace eosiosystem {
total_resources_index_type
total_index
(
SystemAccount
,
del
.
receiver
);
const
auto
&
totals
=
total_index
.
get
(
del
.
receiver
);
total_index
.
update
(
totals
,
0
,
[
&
](
auto
&
tot
)
{
total_index
.
modify
(
totals
,
0
,
[
&
](
auto
&
tot
)
{
tot
.
net_weight
-=
del
.
unstake_net_quantity
;
tot
.
cpu_weight
-=
del
.
unstake_cpu_quantity
;
tot
.
storage_stake
-=
storage_stake_decrease
;
...
...
contracts/eosio.system/eosio.system.hpp
浏览文件 @
84d4b712
...
...
@@ -84,12 +84,12 @@ namespace eosiosystem {
auto
parameters
=
global_state_singleton
::
exists
()
?
global_state_singleton
::
get
()
:
common
<
SystemAccount
>::
get_default_parameters
();
const
system_token_type
block_payment
=
parameters
.
payment_per_block
;
const
auto
*
prod
=
producers_tbl
.
find
(
producer
);
auto
prod
=
producers_tbl
.
find
(
producer
);
// This check is needed when everything works
// eosio_assert(prod != nullptr, "something wrong here");
if
(
prod
!=
nullptr
)
{
if
(
prod
!=
producers_tbl
.
end
()
)
{
// prints("Producer found\n");
producers_tbl
.
update
(
*
prod
,
0
,
[
&
](
auto
&
p
)
{
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
p
)
{
// printi((uint64_t)p.per_block_payments.quantity);
// prints("\n");
p
.
per_block_payments
+=
block_payment
;
...
...
@@ -119,8 +119,8 @@ namespace eosiosystem {
require_auth
(
cr
.
owner
);
eosio_assert
(
current_sender
()
==
account_name
(),
"claimrewards can not be part of a deferred transaction"
);
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
const
auto
*
prod
=
producers_tbl
.
find
(
cr
.
owner
);
eosio_assert
(
prod
!=
nullptr
,
"account name not producer list"
);
auto
prod
=
producers_tbl
.
find
(
cr
.
owner
);
eosio_assert
(
prod
!=
producers_tbl
.
end
()
,
"account name not producer list"
);
eosio_assert
(
prod
->
active
(),
"producer is not active"
);
if
(
prod
->
last_rewards_claim
>
0
)
{
eosio_assert
(
now
()
>=
prod
->
last_rewards_claim
+
seconds_per_day
,
"already claimed rewards within a day"
);
...
...
@@ -156,7 +156,7 @@ namespace eosiosystem {
global_state_singleton
::
set
(
parameters
);
}
}
producers_tbl
.
update
(
*
prod
,
0
,
[
&
](
auto
&
p
)
{
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
p
)
{
p
.
last_rewards_claim
=
now
();
p
.
per_block_payments
.
quantity
=
0
;
});
...
...
@@ -164,9 +164,6 @@ namespace eosiosystem {
currency
::
inline_transfer
(
cr
.
owner
,
SystemAccount
,
rewards
,
"producer claiming rewards"
);
}
static
void
on
(
const
finishundel
&
)
{
}
static
void
apply
(
account_name
code
,
action_name
act
)
{
if
(
!
eosio
::
dispatch
<
currency
,
typename
currency
::
transfer
,
typename
currency
::
issue
>
(
code
,
act
)
)
{
if
(
!
eosio
::
dispatch
<
contract
,
typename
delegate_bandwith
<
SystemAccount
>::
delegatebw
,
...
...
contracts/eosio.system/voting.hpp
浏览文件 @
84d4b712
...
...
@@ -111,10 +111,10 @@ namespace eosiosystem {
require_auth
(
reg
.
producer
);
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
const
auto
*
prod
=
producers_tbl
.
find
(
reg
.
producer
);
auto
prod
=
producers_tbl
.
find
(
reg
.
producer
);
if
(
prod
)
{
producers_tbl
.
update
(
*
prod
,
reg
.
producer
,
[
&
](
producer_info
&
info
){
if
(
prod
!=
producers_tbl
.
end
()
)
{
producers_tbl
.
modify
(
prod
,
reg
.
producer
,
[
&
](
producer_info
&
info
){
info
.
prefs
=
reg
.
prefs
;
info
.
packed_key
=
reg
.
producer_key
;
});
...
...
@@ -138,26 +138,26 @@ namespace eosiosystem {
require_auth
(
unreg
.
producer
);
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
const
auto
*
prod
=
producers_tbl
.
find
(
unreg
.
producer
);
eosio_assert
(
bool
(
prod
),
"producer not found"
);
auto
prod
=
producers_tbl
.
find
(
unreg
.
producer
);
eosio_assert
(
prod
!=
producers_tbl
.
end
(
),
"producer not found"
);
producers_tbl
.
update
(
*
prod
,
0
,
[
&
](
producer_info
&
info
){
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
);
const
auto
*
voter
=
voters_tbl
.
find
(
acnt
);
auto
voter
=
voters_tbl
.
find
(
acnt
);
if
(
!
voter
)
{
voter
=
&
voters_tbl
.
emplace
(
acnt
,
[
&
](
voter_info
&
a
)
{
if
(
voter
==
voters_tbl
.
end
()
)
{
voter
=
voters_tbl
.
emplace
(
acnt
,
[
&
](
voter_info
&
a
)
{
a
.
owner
=
acnt
;
a
.
last_update
=
now
();
a
.
staked
=
amount
;
});
}
else
{
voters_tbl
.
update
(
*
voter
,
0
,
[
&
](
auto
&
av
)
{
voters_tbl
.
modify
(
voter
,
0
,
[
&
](
auto
&
av
)
{
av
.
last_update
=
now
();
av
.
staked
+=
amount
;
});
...
...
@@ -166,8 +166,8 @@ namespace eosiosystem {
const
std
::
vector
<
account_name
>*
producers
=
nullptr
;
if
(
voter
->
proxy
)
{
auto
proxy
=
voters_tbl
.
find
(
voter
->
proxy
);
eosio_assert
(
bool
(
proxy
),
"selected proxy not found"
);
//data corruption
voters_tbl
.
update
(
*
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
proxied_votes
+=
amount
.
quantity
;
}
);
eosio_assert
(
proxy
!=
voters_tbl
.
end
(
),
"selected proxy not found"
);
//data corruption
voters_tbl
.
modify
(
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
proxied_votes
+=
amount
.
quantity
;
}
);
if
(
proxy
->
is_proxy
)
{
//only if proxy is still active. if proxy has been unregistered, we update proxied_votes, but don't propagate to producers
producers
=
&
proxy
->
producers
;
}
...
...
@@ -179,8 +179,8 @@ namespace eosiosystem {
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
for
(
auto
p
:
*
producers
)
{
auto
prod
=
producers_tbl
.
find
(
p
);
eosio_assert
(
bool
(
prod
),
"never existed producer"
);
//data corruption
producers_tbl
.
update
(
*
prod
,
0
,
[
&
](
auto
&
v
)
{
eosio_assert
(
prod
!=
producers_tbl
.
end
(
),
"never existed producer"
);
//data corruption
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
v
)
{
v
.
total_votes
+=
amount
.
quantity
;
});
}
...
...
@@ -190,8 +190,8 @@ namespace eosiosystem {
static
void
decrease_voting_power
(
account_name
acnt
,
system_token_type
amount
)
{
require_auth
(
acnt
);
voters_table
voters_tbl
(
SystemAccount
,
SystemAccount
);
const
auto
*
voter
=
voters_tbl
.
find
(
acnt
);
eosio_assert
(
bool
(
voter
),
"stake not found"
);
auto
voter
=
voters_tbl
.
find
(
acnt
);
eosio_assert
(
voter
!=
voters_tbl
.
end
(
),
"stake not found"
);
if
(
0
<
amount
.
quantity
)
{
eosio_assert
(
amount
<=
voter
->
staked
,
"cannot unstake more than total stake amount"
);
...
...
@@ -204,7 +204,7 @@ namespace eosiosystem {
dt.voter = acnt;
uint32_t new_trx_id = 0;//XXX send_deferred(dt);
avotes.
update( *
voter, 0, [&](voter_info& a) {
avotes.
modify(
voter, 0, [&](voter_info& a) {
a.staked -= amount;
a.unstaking += a.unstaking + amount;
//round up to guarantee that there will be no unpaid balance after 26 weeks, and we are able refund amount < unstake_payments
...
...
@@ -215,7 +215,7 @@ namespace eosiosystem {
*/
// Temporary code: immediate unstake
voters_tbl
.
update
(
*
voter
,
0
,
[
&
](
voter_info
&
a
)
{
voters_tbl
.
modify
(
voter
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
staked
-=
amount
;
a
.
last_update
=
now
();
});
...
...
@@ -225,7 +225,7 @@ namespace eosiosystem {
const
std
::
vector
<
account_name
>*
producers
=
nullptr
;
if
(
voter
->
proxy
)
{
auto
proxy
=
voters_tbl
.
find
(
voter
->
proxy
);
voters_tbl
.
update
(
*
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
proxied_votes
-=
amount
.
quantity
;
}
);
voters_tbl
.
modify
(
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
proxied_votes
-=
amount
.
quantity
;
}
);
if
(
proxy
->
is_proxy
)
{
//only if proxy is still active. if proxy has been unregistered, we update proxied_votes, but don't propagate to producers
producers
=
&
proxy
->
producers
;
}
...
...
@@ -237,8 +237,8 @@ namespace eosiosystem {
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
for
(
auto
p
:
*
producers
)
{
auto
prod
=
producers_tbl
.
find
(
p
);
eosio_assert
(
bool
(
prod
),
"never existed producer"
);
//data corruption
producers_tbl
.
update
(
*
prod
,
0
,
[
&
](
auto
&
v
)
{
eosio_assert
(
prod
!=
producers_tbl
.
end
(
),
"never existed producer"
);
//data corruption
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
v
)
{
v
.
total_votes
-=
amount
.
quantity
;
});
}
...
...
@@ -247,7 +247,7 @@ namespace eosiosystem {
if
(
voter
->
deferred_trx_id
)
{
//XXX cancel_deferred_transaction(voter->deferred_trx_id);
}
voters_tbl
.
update
(
*
voter
,
0
,
[
&
](
voter_info
&
a
)
{
voters_tbl
.
modify
(
voter
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
staked
+=
a
.
unstaking
;
a
.
unstaking
.
quantity
=
0
;
a
.
unstake_per_week
.
quantity
=
0
;
...
...
@@ -421,8 +421,8 @@ namespace eosiosystem {
static
void
on
(
const
unstake_vote_deferred
&
usv
)
{
require_auth
(
usv
.
voter
);
voters_table
voters_tbl
(
SystemAccount
,
SystemAccount
);
const
auto
*
voter
=
voters_tbl
.
find
(
usv
.
voter
);
eosio_assert
(
bool
(
voter
),
"stake not found"
);
auto
voter
=
voters_tbl
.
find
(
usv
.
voter
);
eosio_assert
(
voter
!=
voters_tbl
.
end
(
),
"stake not found"
);
auto
weeks
=
(
now
()
-
voter
->
last_unstake_time
)
/
unstake_pay_period
;
eosio_assert
(
0
==
weeks
,
"less than one week passed since last transfer or unstake request"
);
...
...
@@ -433,7 +433,7 @@ namespace eosiosystem {
currency
::
inline_transfer
(
SystemAccount
,
usv
.
voter
,
unstake_amount
,
"unstake voting"
);
voters_tbl
.
update
(
*
voter
,
0
,
[
&
](
voter_info
&
a
)
{
voters_tbl
.
modify
(
voter
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
unstaking
-=
unstake_amount
;
a
.
deferred_trx_id
=
new_trx_id
;
a
.
last_unstake_time
=
a
.
last_unstake_time
+
weeks
*
unstake_pay_period
;
...
...
@@ -472,7 +472,7 @@ namespace eosiosystem {
voters_table
voters_tbl
(
SystemAccount
,
SystemAccount
);
auto
voter
=
voters_tbl
.
find
(
vp
.
voter
);
eosio_assert
(
bool
(
voter
)
&&
(
0
<
voter
->
staked
.
quantity
||
(
voter
->
is_proxy
&&
0
<
voter
->
proxied_votes
)
),
"no stake to vote"
);
eosio_assert
(
voter
!=
voters_tbl
.
end
(
)
&&
(
0
<
voter
->
staked
.
quantity
||
(
voter
->
is_proxy
&&
0
<
voter
->
proxied_votes
)
),
"no stake to vote"
);
if
(
voter
->
is_proxy
)
{
eosio_assert
(
vp
.
proxy
==
0
,
"account registered as a proxy is not allowed to use a proxy"
);
}
...
...
@@ -484,8 +484,8 @@ namespace eosiosystem {
return
;
// nothing changed
}
auto
old_proxy
=
voters_tbl
.
find
(
voter
->
proxy
);
eosio_assert
(
bool
(
old_proxy
),
"old proxy not found"
);
//data corruption
voters_tbl
.
update
(
*
old_proxy
,
0
,
[
&
](
auto
&
a
)
{
a
.
proxied_votes
-=
voter
->
staked
.
quantity
;
}
);
eosio_assert
(
old_proxy
!=
voters_tbl
.
end
(
),
"old proxy not found"
);
//data corruption
voters_tbl
.
modify
(
old_proxy
,
0
,
[
&
](
auto
&
a
)
{
a
.
proxied_votes
-=
voter
->
staked
.
quantity
;
}
);
if
(
old_proxy
->
is_proxy
)
{
//if proxy stoped being proxy, the votes were already taken back from producers by on( const unregister_proxy& )
old_producers
=
&
old_proxy
->
producers
;
}
...
...
@@ -497,8 +497,8 @@ namespace eosiosystem {
const
std
::
vector
<
account_name
>*
new_producers
=
nullptr
;
if
(
vp
.
proxy
)
{
auto
new_proxy
=
voters_tbl
.
find
(
vp
.
proxy
);
eosio_assert
(
new_proxy
&&
new_proxy
->
is_proxy
,
"proxy not found"
);
voters_tbl
.
update
(
*
new_proxy
,
0
,
[
&
](
auto
&
a
)
{
a
.
proxied_votes
+=
voter
->
staked
.
quantity
;
}
);
eosio_assert
(
new_proxy
!=
voters_tbl
.
end
()
&&
new_proxy
->
is_proxy
,
"proxy not found"
);
voters_tbl
.
modify
(
new_proxy
,
0
,
[
&
](
auto
&
a
)
{
a
.
proxied_votes
+=
voter
->
staked
.
quantity
;
}
);
new_producers
=
&
new_proxy
->
producers
;
}
else
{
new_producers
=
&
vp
.
producers
;
...
...
@@ -516,8 +516,8 @@ namespace eosiosystem {
auto
end_it
=
std
::
set_difference
(
old_producers
->
begin
(),
old_producers
->
end
(),
new_producers
->
begin
(),
new_producers
->
end
(),
revoked
.
begin
()
);
for
(
auto
it
=
revoked
.
begin
();
it
!=
end_it
;
++
it
)
{
auto
prod
=
producers_tbl
.
find
(
*
it
);
eosio_assert
(
bool
(
prod
),
"never existed producer"
);
//data corruption
producers_tbl
.
update
(
*
prod
,
0
,
[
&
](
auto
&
pi
)
{
pi
.
total_votes
-=
votes
;
}
);
eosio_assert
(
prod
!=
producers_tbl
.
end
(
),
"never existed producer"
);
//data corruption
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
pi
)
{
pi
.
total_votes
-=
votes
;
}
);
}
}
...
...
@@ -526,15 +526,15 @@ namespace eosiosystem {
auto
end_it
=
std
::
set_difference
(
new_producers
->
begin
(),
new_producers
->
end
(),
old_producers
->
begin
(),
old_producers
->
end
(),
elected
.
begin
()
);
for
(
auto
it
=
elected
.
begin
();
it
!=
end_it
;
++
it
)
{
auto
prod
=
producers_tbl
.
find
(
*
it
);
eosio_assert
(
bool
(
prod
),
"producer is not registered"
);
eosio_assert
(
prod
!=
producers_tbl
.
end
(
),
"producer is not registered"
);
if
(
vp
.
proxy
==
0
)
{
//direct voting, in case of proxy voting update total_votes even for inactive producers
eosio_assert
(
prod
->
active
(),
"producer is not currently registered"
);
}
producers_tbl
.
update
(
*
prod
,
0
,
[
&
](
auto
&
pi
)
{
pi
.
total_votes
+=
votes
;
}
);
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
pi
)
{
pi
.
total_votes
+=
votes
;
}
);
}
// save new values to the account itself
voters_tbl
.
update
(
*
voter
,
0
,
[
&
](
voter_info
&
a
)
{
voters_tbl
.
modify
(
voter
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
proxy
=
vp
.
proxy
;
a
.
last_update
=
now
();
a
.
producers
=
vp
.
producers
;
...
...
@@ -552,10 +552,10 @@ namespace eosiosystem {
voters_table
voters_tbl
(
SystemAccount
,
SystemAccount
);
auto
proxy
=
voters_tbl
.
find
(
reg
.
proxy
);
if
(
proxy
)
{
if
(
proxy
!=
voters_tbl
.
end
()
)
{
eosio_assert
(
proxy
->
is_proxy
==
0
,
"account is already a proxy"
);
eosio_assert
(
proxy
->
proxy
==
0
,
"account that uses a proxy is not allowed to become a proxy"
);
voters_tbl
.
update
(
*
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
voters_tbl
.
modify
(
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
is_proxy
=
1
;
a
.
last_update
=
now
();
//a.proxied_votes may be > 0, if the proxy has been unregistered, so we had to keep the value
...
...
@@ -564,8 +564,8 @@ namespace eosiosystem {
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
for
(
auto
p
:
proxy
->
producers
)
{
auto
prod
=
producers_tbl
.
find
(
p
);
eosio_assert
(
bool
(
prod
),
"never existed producer"
);
//data corruption
producers_tbl
.
update
(
*
prod
,
0
,
[
&
](
auto
&
pi
)
{
pi
.
total_votes
+=
proxy
->
proxied_votes
;
});
eosio_assert
(
prod
!=
producers_tbl
.
end
(
),
"never existed producer"
);
//data corruption
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
pi
)
{
pi
.
total_votes
+=
proxy
->
proxied_votes
;
});
}
}
}
else
{
...
...
@@ -591,10 +591,10 @@ namespace eosiosystem {
voters_table
voters_tbl
(
SystemAccount
,
SystemAccount
);
auto
proxy
=
voters_tbl
.
find
(
reg
.
proxy
);
eosio_assert
(
bool
(
proxy
),
"proxy not found"
);
eosio_assert
(
proxy
==
voters_tbl
.
end
(
),
"proxy not found"
);
eosio_assert
(
proxy
->
is_proxy
==
1
,
"account is not a proxy"
);
voters_tbl
.
update
(
*
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
voters_tbl
.
modify
(
proxy
,
0
,
[
&
](
voter_info
&
a
)
{
a
.
is_proxy
=
0
;
a
.
last_update
=
now
();
//a.proxied_votes should be kept in order to be able to reenable this proxy in the future
...
...
@@ -604,8 +604,8 @@ namespace eosiosystem {
producers_table
producers_tbl
(
SystemAccount
,
SystemAccount
);
for
(
auto
p
:
proxy
->
producers
)
{
auto
prod
=
producers_tbl
.
find
(
p
);
eosio_assert
(
bool
(
prod
),
"never existed producer"
);
//data corruption
producers_tbl
.
update
(
*
prod
,
0
,
[
&
](
auto
&
pi
)
{
pi
.
total_votes
-=
proxy
->
proxied_votes
;
});
eosio_assert
(
prod
!=
producers_tbl
.
end
(
),
"never existed producer"
);
//data corruption
producers_tbl
.
modify
(
prod
,
0
,
[
&
](
auto
&
pi
)
{
pi
.
total_votes
-=
proxy
->
proxied_votes
;
});
}
}
}
...
...
contracts/eosiolib/generic_currency.hpp
浏览文件 @
84d4b712
...
...
@@ -146,7 +146,7 @@ namespace eosio {
static
token_type
get_total_supply
()
{
stats
t
(
code
,
code
);
auto
ptr
=
t
.
find
(
symbol
);
return
ptr
?
ptr
->
supply
:
token_type
(
0
);
return
ptr
!=
t
.
end
()
?
ptr
->
supply
:
token_type
(
0
);
}
static
void
apply
(
account_name
c
,
action_name
act
)
{
...
...
contracts/eosiolib/singleton.hpp
浏览文件 @
84d4b712
...
...
@@ -30,7 +30,7 @@ namespace eosio {
static
bool
exists
(
scope_name
scope
=
Code
)
{
table
t
(
Code
,
scope
);
return
t
.
find
(
pk_value
);
return
t
.
find
(
pk_value
)
!=
t
.
end
()
;
}
static
T
get
(
scope_name
scope
=
Code
)
{
...
...
contracts/eosiolib/token.hpp
浏览文件 @
84d4b712
...
...
@@ -46,7 +46,7 @@ namespace eosio {
template
<
typename
Base
,
typename
Quote
>
friend
price
<
Base
,
Quote
>
operator
/
(
const
Base
&
b
,
const
Quote
&
q
);
operator
asset
()
const
{
return
asset
(
int64_t
(
quantity
),
Symbol
);
}
explicit
operator
asset
()
const
{
return
asset
(
int64_t
(
quantity
),
Symbol
);
}
token
(
const
asset
&
a
)
:
quantity
(
NumberType
(
a
.
amount
))
{
eosio_assert
(
a
.
symbol
==
Symbol
,
"attempt to construct token from asset with different symbol"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录