提交 4ad559c7 编写于 作者: W wangxxzhiyy

update contracts

上级 beabe753
......@@ -180,7 +180,21 @@
"type": "int64"
}
]
}
},
{
"name": "mchgdepacc",
"base": "",
"fields": [
{
"name": "minerid",
"type": "uint64"
},
{
"name": "new_depacc",
"type": "name"
}
]
}
],
"actions": [
{
......@@ -217,6 +231,11 @@
"name": "setrate",
"type": "setrate",
"ricardian_contract": ""
},
{
"name": "mchgdepacc",
"type": "mchgdepacc",
"ricardian_contract": ""
}
],
"tables": [
......
......@@ -259,6 +259,40 @@ void hdddeposit::setrate(int64_t rate) {
}
void hdddeposit::mchgdepacc(uint64_t minerid, name new_depacc) {
require_auth(new_depacc);
minerdeposit_table _mdeposit(_self, _self);
const auto& miner = _mdeposit.get( minerid, "no deposit record for this minerid");
eosio_assert(miner.account_name != new_depacc, "must use different account to change deposit user");
depositpool_table _deposit_old(_self, miner.account_name.value);
const auto& acc_old = _deposit_old.get( miner.account_name, "no deposit pool record for original deposit user");
depositpool_table _deposit_new(_self, new_depacc.value);
const auto& acc_new = _deposit_new.get( new_depacc.value, "no deposit pool record for new deposit user");
eosio_assert( acc_new.deposit_free.amount >= miner.dep_total.amount, "new deposit user free deposit not enough" );
eosio_assert(hddpool::get_miner_pool(minerid) == new_depacc, "minerid not exist in new_depacc's storepool ");
//变更原抵押账户的押金数量
_deposit_old.modify( acc_old, 0, [&]( auto& a ) {
a.deposit_free += miner.deposit;
});
//将矿机的押金数量重新恢复到未扣罚金的初始额度
_mdeposit.modify( miner, 0, [&]( auto& a ) {
a.account_name = new_depacc;
a.deposit = a.dep_total;
});
_deposit_new.modify( acc_new, 0, [&]( auto& a ) {
a.deposit_free -= miner.dep_total;
});
}
void hdddeposit::check_bp_account(account_name bpacc, uint64_t id, bool isCheckId) {
account_name shadow;
uint64_t seq_num = eosiosystem::getProducerSeq(bpacc, shadow);
......@@ -272,4 +306,4 @@ void hdddeposit::check_bp_account(account_name bpacc, uint64_t id, bool isCheckI
EOSIO_ABI( hdddeposit, (paydeppool)(unpaydeppool)(paydeposit)(chgdeposit)(payforfeit)(delminer)(setrate))
EOSIO_ABI( hdddeposit, (paydeppool)(unpaydeppool)(paydeposit)(chgdeposit)(payforfeit)(delminer)(setrate)(mchgdepacc))
......@@ -25,6 +25,8 @@ class hdddeposit : public eosio::contract {
void delminer(uint64_t minerid);
void setrate(int64_t rate);
void mchgdepacc(uint64_t minerid, name new_depacc);
inline asset get_deposit( account_name user )const;
inline asset get_miner_deposit( uint64_t minerid )const;
inline bool is_deposit_enough( asset deposit, uint64_t max_space ) const;
......
......@@ -196,6 +196,16 @@
}
]
},
{
"name": "calcprofit",
"base": "",
"fields": [
{
"name": "user",
"type": "name"
}
]
},
{
"name": "mchgspace",
"base": "",
......@@ -547,7 +557,7 @@
]
},
{
"name": "useracchdd",
"name": "userhddinfo",
"base": "",
"fields": [
{
......@@ -558,25 +568,33 @@
"name": "hdd_storehdd",
"type": "int64"
},
{
"name": "hdd_minerhdd",
"type": "int64"
},
{
"name": "hdd_per_cycle_fee",
"type": "int64"
},
{
"name": "hdd_space",
"name": "hdd_space_store",
"type": "uint64"
},
{
"name": "last_hdd_time",
"name": "last_hddstore_time",
"type": "uint64"
},
{
"name": "hdd_minerhdd",
"type": "int64"
},
{
"name": "hdd_per_cycle_profit",
"type": "int64"
},
{
"name": "hdd_space_profit",
"type": "uint64"
},
{
"name": "last_hddprofit_time",
"type": "uint64"
}
]
},
......@@ -674,6 +692,11 @@
"type": "getbalance",
"ricardian_contract": ""
},
{
"name": "calcprofit",
"type": "calcprofit",
"ricardian_contract": ""
},
{
"name": "sellhdd",
"type": "sellhdd",
......@@ -816,8 +839,8 @@
"key_types": []
},
{
"name": "useracchdd",
"type": "useracchdd",
"name": "userhddinfo",
"type": "userhddinfo",
"index_type": "i64",
"key_names": [],
"key_types": []
......
此差异已折叠。
......@@ -23,6 +23,7 @@ public:
~hddpool();
void getbalance(name user, uint8_t acc_type, name caller);
void calcprofit(name user);
void buyhdd(name from, name receiver, int64_t amount);
void sellhdd(name user, int64_t amount);
void sethfee(name user, int64_t fee, name caller);
......@@ -48,6 +49,7 @@ public:
//change miner info related actions
void mchgadminacc(uint64_t minerid, name new_adminacc);
void mchgowneracc(uint64_t minerid, name new_owneracc);
void mchgstrpool(uint64_t minerid, name new_poolid);
void mchgspace(uint64_t minerid, uint64_t max_space);
//update hddpool params
......@@ -62,14 +64,16 @@ private:
{
name account_name; //账户名
int64_t hdd_storehhdd; //用户数据存储的HDD数量
int64_t hdd_minerhdd; //存储服务提供者的HDD收益数量
int64_t hdd_per_cycle_fee; //用户存储数据的每周期费用
uint64_t hdd_space; //用户存储数据占用的存储空间
uint64_t last_hdd_time; //上次余额计算时间 microseconds from 1970
int64_t hdd_per_cycle_profit; //reserve
uint64_t hdd_space_store; //用户存储数据占用的存储空间
uint64_t last_hddstore_time; //上次存储hdd余额计算时间 microseconds from 1970
int64_t hdd_minerhdd; //存储服务提供者的HDD收益数量
int64_t hdd_per_cycle_profit; //每周期收益
uint64_t hdd_space_profit; //该收益账户名下所有矿机的总生产空间
uint64_t last_hddprofit_time; //上次收益hdd余额计算时间 microseconds from 1970
uint64_t primary_key() const { return account_name.value; }
};
typedef multi_index<N(useracchdd), userhdd> userhdd_index;
typedef multi_index<N(userhddinfo), userhdd> userhdd_index;
struct maccount
{
......@@ -211,25 +215,16 @@ public:
return 0;
}
};
/*
bool hddpool::is_miner_exist(uint64_t minerid) const
{
minerinfo_table _minerinfo( _self , _self );
auto itminerinfo = _minerinfo.find(minerid);
if(itminerinfo != _minerinfo.end())
return true;
static name get_miner_pool(uint64_t minerid)
{
name pool;
minerinfo_table _minerinfo( N(hddpool12345) , N(hddpool12345) );
auto itminerinfo = _minerinfo.find(minerid);
if(itminerinfo != _minerinfo.end()) {
pool = itminerinfo->owner;
}
return pool;
}
return false;
}
};
uint64_t hddpool::get_miner_max_space(uint64_t minerid) const
{
minerinfo_table _minerinfo( _self , _self );
auto itminerinfo = _minerinfo.find(minerid);
if(itminerinfo != _minerinfo.end())
return itminerinfo->max_space;
return 0;
}
*/
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册