提交 41e30d17 编写于 作者: W Wang Zhi

update contracts

上级 8d145e93
......@@ -281,6 +281,13 @@
{"name":"last_claim_time", "type":"uint64"}
]
},{
"name": "eosio_global_state3",
"base": "",
"fields": [
{"name":"is_schedule", "type":"bool"}
]
},
{
"name": "eosio_global_count",
"base": "",
"fields": [
......@@ -306,8 +313,6 @@
{"name":"owner", "type":"account_name"},
{"name":"seq_num", "type":"uint16"},
{"name":"level", "type":"uint8"},
{"name":"out_votes", "type":"int64"},
{"name":"deposit_votes", "type":"int64"},
{"name":"unpaid_base_cnt", "type":"uint32"},
{"name":"unpaid_amount", "type":"int64"},
{"name":"shadow", "type":"account_name"}
......@@ -378,6 +383,12 @@
"fields": [
{"name":"voter_name", "type":"account_name"}
]
},{
"name": "setautosche",
"base": "",
"fields": [
{"name":"auto_sche", "type":"bool"}
]
},{
"name": "voter_info",
"base": "",
......@@ -583,6 +594,10 @@
"name": "changevotes",
"type": "changevotes",
"ricardian_contract": ""
},{
"name": "setautosche",
"type": "setautosche",
"ricardian_contract": ""
},{
"name": "claimrewards",
"type": "claimrewards",
......@@ -654,6 +669,12 @@
"index_type": "i64",
"key_names" : [],
"key_types" : []
},{
"name": "globalext2",
"type": "eosio_global_state3",
"index_type": "i64",
"key_names" : [],
"key_types" : []
},{
"name": "gcount",
"type": "eosio_global_count",
......
......@@ -209,7 +209,7 @@ EOSIO_ABI( eosiosystem::system_contract,
// delegate_bandwidth.cpp
(buyrambytes)(buyram)(sellram)(delegatebw)(undelegatebw)(refund)
// voting.cpp
(regproducer)(unregprod)(voteproducer)(changevotes)(regproxy)(clsprods2)(seqproducer)(reprodlevel)
(regproducer)(unregprod)(voteproducer)(changevotes)(regproxy)(clsprods2)(seqproducer)(reprodlevel)(setautosche)
// producer_pay.cpp
(onblock)(claimrewards)(rewardprods)(startreward)
)
......@@ -75,6 +75,13 @@ namespace eosiosystem {
EOSLIB_SERIALIZE( eosio_global_count, (total_accounts) )
};
struct eosio_global_state3 {
bool is_schedule = true;
EOSLIB_SERIALIZE( eosio_global_state3, (is_schedule) )
};
//##YTA-Change end:
struct producer_info {
......@@ -102,14 +109,12 @@ namespace eosiosystem {
account_name owner;
uint16_t seq_num = 1; // from 1 to 21
uint8_t level = 3;
int64_t out_votes = 0;
int64_t deposit_votes = 0;
uint32_t unpaid_base_cnt = 0;
int64_t unpaid_amount = 0;
account_name shadow = 0;
uint64_t primary_key()const { return owner; }
EOSLIB_SERIALIZE( producer_info_ext, (owner)(seq_num)(level)(out_votes)(deposit_votes)(unpaid_base_cnt)(unpaid_amount)(shadow))
EOSLIB_SERIALIZE( producer_info_ext, (owner)(seq_num)(level)(unpaid_base_cnt)(unpaid_amount)(shadow))
};
//##YTA-Change end:
......@@ -184,6 +189,7 @@ namespace eosiosystem {
//##YTA-Change start:
typedef eosio::singleton<N(globalext), eosio_global_state2> global_state2_singleton;
typedef eosio::singleton<N(globalext2), eosio_global_state3> global_state3_singleton;
typedef eosio::singleton<N(gcount), eosio_global_count> global_count_singleton;
//##YTA-Change end:
......@@ -278,6 +284,8 @@ namespace eosiosystem {
void reprodlevel();
void changevotes( const account_name voter_name );
void setautosche( bool auto_sche);
//##YTA-Change end:
void setram( uint64_t max_ram_size );
......
......@@ -90,13 +90,6 @@ namespace eosiosystem {
require_auth(N(ytaadminuser));
while (_producersext.begin() != _producersext.end()) {
auto it = _producersext.begin();
//it->out_votes
const auto& prod = _producers.get( it->owner, "producer not found" );
_producers.modify( prod, 0, [&]( producer_info& info ){
info.total_votes -= it->out_votes;
});
_gstate.total_producer_vote_weight -= it->out_votes;
_producersext.erase(_producersext.begin());
}
......@@ -418,8 +411,38 @@ namespace eosiosystem {
}
void system_contract::setautosche( bool auto_sche) {
require_auth(N(ytaadminuser));
global_state3_singleton _globalext2(_self, _self);
eosio_global_state3 _global_state3;
if (_globalext2.exists()) {
_global_state3 = _globalext2.get();
} else {
_global_state3 = eosio_global_state3{};
}
_global_state3.is_schedule = auto_sche;
_globalext2.set(_global_state3,_self);
}
void system_contract::update_elected_producers_yta( block_timestamp block_time ) {
global_state3_singleton _globalext2(_self, _self);
eosio_global_state3 _global_state3;
bool isSchedule = true;
if (_globalext2.exists()) {
_global_state3 = _globalext2.get();
isSchedule = _global_state3.is_schedule;
}
if(!isSchedule)
return;
all_prods_singleton _all_prods(_self, _self);
all_prods_level _all_prods_state;
......
......@@ -122,7 +122,7 @@ void token::sub_balance_yta( account_name owner, asset value , account_name to)
bool is_frozen = hddlock(hdd_lock_account).is_frozen(owner);
//todo : need consider lock_token situation
if( to == hdd_deposit_account) { //缴纳罚金,锁仓币也可以缴纳罚金
if( to == N(yottaforfeit)) { //缴纳罚金,锁仓币也可以缴纳罚金
eosio_assert( from.balance.amount >= value.amount, "overdrawn balance" );
} else if( to == N(eosio.stake) ) { //用来抵押带宽和CPU
eosio_assert( !is_frozen, "user is frozen" );
......
......@@ -15,7 +15,6 @@ using namespace eosio;
static constexpr eosio::name active_permission{N(active)};
static constexpr eosio::name token_account{N(eosio.token)};
static constexpr eosio::name system_account{N(eosio)};
static constexpr eosio::name hdd_deposit_account{N(hdddeposit12)};
static constexpr eosio::name hdd_lock_account{N(hddlock12345)};
......@@ -196,7 +195,7 @@ void hdddeposit::payforfeit(name user, uint64_t minerid, asset quant, uint8_t ac
action(
permission_level{user, active_permission},
token_account, N(transfer),
std::make_tuple(user, hdd_deposit_account, quant, std::string("draw forfeit")))
std::make_tuple(user, N(yottaforfeit), quant, std::string("draw forfeit")))
.send();
if( eosiosystem::isActiveVoter(user) ) {
......
......@@ -96,14 +96,23 @@ void hddlock::locktransfer(uint64_t lockruleid, account_name from, account_name
}
acclock_table _acclock(_self, to);
_acclock.emplace(_self, [&](auto &row) {
row.quantity = quantity;
row.lockruleid = lockruleid;
row.user = to;
row.from = from;
row.memo = memo;
row.time = current_time();
});
auto itlc = _acclock.find(lockruleid);
if(itlc != _acclock.end()) {
_acclock.modify(itlc, _self, [&](auto &row) {
row.time = current_time();
row.quantity += quantity;
});
} else {
_acclock.emplace(_self, [&](auto &row) {
row.quantity = quantity;
row.lockruleid = lockruleid;
row.user = to;
row.from = from;
row.memo = memo;
row.time = current_time();
});
}
}
void hddlock::frozenuser(account_name user, uint64_t time) {
......
......@@ -47,7 +47,7 @@ class hddlock : public eosio::contract {
account_name from;
std::string memo;
uint64_t time;
uint64_t primary_key()const { return time; }
uint64_t primary_key()const { return lockruleid; }
};
typedef multi_index<N(acclock), acclock> acclock_table;
......
......@@ -36,7 +36,7 @@ const uint64_t max_minerspace = 64 * 1024 * uint64_t(1024 * 100); //100T 单个
static constexpr eosio::name active_permission{N(active)};
static constexpr eosio::name token_account{N(eosio.token)};
static constexpr eosio::name hdd_account{N(hddpool12345)};
static constexpr eosio::name hdd_exchg_acc{N(hddpoolexchg)};
static constexpr eosio::name hdd_deposit{N(hdddeposit12)};
static constexpr int64_t max_hdd_amount = (1LL << 62) - 1;
......@@ -229,7 +229,7 @@ void hddpool::buyhdd(name from, name receiver, asset quant)
eosio_assert(is_account(from), "user not a account");
eosio_assert(is_account(receiver), "receiver not a account");
eosio_assert(is_account(hdd_account), "to not a account");
eosio_assert(is_account(hdd_exchg_acc), "to not a account");
eosio_assert(quant.is_valid(), "asset is invalid");
eosio_assert(quant.symbol == CORE_SYMBOL, "must use core asset to buy HDD");
eosio_assert(quant.amount > 0, "must transfer positive quantity");
......@@ -238,7 +238,7 @@ void hddpool::buyhdd(name from, name receiver, asset quant)
action(
permission_level{from, active_permission},
token_account, N(transfer),
std::make_tuple(from, hdd_account, quant, std::string("buy hdd")))
std::make_tuple(from, hdd_exchg_acc, quant, std::string("buy hdd")))
.send();
int64_t _hdd_amount = 0;
......@@ -300,9 +300,9 @@ void hddpool::sellhdd(name user, int64_t amount)
asset quant{_yta_amount, CORE_SYMBOL};
action(
permission_level{hdd_account, active_permission},
permission_level{hdd_exchg_acc, active_permission},
token_account, N(transfer),
std::make_tuple(hdd_account, user, quant, std::string("sell hdd")))
std::make_tuple(hdd_exchg_acc, user, quant, std::string("sell hdd")))
.send();
update_total_hdd_balance(-amount);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册