提交 8caa2db6 编写于 作者: W Wang Zhi

update hdddata for some type conversion issue

上级 eb134438
......@@ -30,6 +30,7 @@ add_subdirectory(noop)
add_subdirectory(tic_tac_toe)
add_subdirectory(payloadless)
add_subdirectory(integration_test)
add_subdirectory(hddpool)
add_subdirectory(hdddeposit)
......
file(GLOB ABI_FILES "*.abi")
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
add_wast_executable(TARGET hddpool
INCLUDE_FOLDERS ${STANDARD_INCLUDE_FOLDERS}
LIBRARIES libc++ libc eosiolib eosio.token
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR}
)
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.1",
"version": "eosio::abi/1.0",
"types": [],
"structs": [
{
......@@ -111,7 +110,7 @@
"type": "name"
},
{
"name": "mount",
"name": "amount",
"type": "int64"
}
]
......@@ -126,7 +125,7 @@
},
{
"name": "fee",
"type": "uint64"
"type": "int64"
}
]
},
......@@ -140,7 +139,7 @@
},
{
"name": "balance",
"type": "uint64"
"type": "int64"
}
]
},
......@@ -168,15 +167,15 @@
},
{
"name": "hdd_balance",
"type": "uint64"
"type": "int64"
},
{
"name": "hdd_per_cycle_fee",
"type": "uint64"
"type": "int64"
},
{
"name": "hdd_per_cycle_profit",
"type": "uint64"
"type": "int64"
},
{
"name": "hdd_space",
......
......@@ -2,46 +2,49 @@
#include <eosiolib/action.hpp>
#include <eosiolib/chain.h>
#include <eosiolib/symbol.hpp>
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/serialize.hpp>
#include <eosiolib/multi_index.hpp>
//#include <eosio.token/eosio.token.hpp>
using namespace eosio;
static constexpr symbol hddcore_symbol = symbol(symbol_code("HDDCORE"), 4);
static constexpr symbol hdd_symbol = symbol(symbol_code("HDD"), 0);
#include <cmath>
#include <string>
#include <type_traits>
#include <optional>
static constexpr eosio::name active_permission{"active"_n};
static constexpr eosio::name token_account{"eosio.token"_n};
static constexpr eosio::name hdd_account{"hddpool12345"_n};
static constexpr symbol yta_symbol = symbol(symbol_code("YTA"), 4);
using namespace eosio;
const uint32_t hours_in_one_day = 24;
const uint32_t minutes_in_one_day = hours_in_one_day * 60;
const uint32_t seconds_in_one_day = minutes_in_one_day * 60;
const uint32_t seconds_in_one_week = seconds_in_one_day * 7;
//const uint32_t seconds_in_one_week = seconds_in_one_day * 7;
const uint32_t seconds_in_one_year = seconds_in_one_day * 365;
const int64_t useconds_per_day = 24 * 3600 * int64_t(1000000);
//const int64_t useconds_per_day = 24 * 3600 * int64_t(1000000);
const uint32_t fee_cycle = 30 ; //计费周期(秒为单位)
const uint32_t one_gb = 1024*1024*1024; //1GB
const uint32_t data_slice_size = 16*1024; // among 4k-32k,set it as 16k
const name HDD_OFFICIAL = "hddofficial"_n;
const uint64_t inc_hdd_amount = 1000000000;
static constexpr eosio::name HDD_OFFICIAL{N(hddofficial)};
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)};
hddpool::hddpool( name s, name code, datastream<const char*> ds )
:contract(s, code, ds),
_global(_self, _self.value)
const int64_t inc_hdd_amount = 1000000000;
hddpool::hddpool( account_name s)
:contract(s),
_global(_self, _self)
{
//print("------hddpool::hddpool-----\n");
if(_global.exists())
_gstate = _global.get();
else {
else
_gstate = hdd_global_state{};
//int i = 0;
}
}
hddpool::~hddpool()
......@@ -57,12 +60,12 @@ hddpool::hdd_global_state hddpool::get_default_param() {
return dp;
}
ACTION hddpool::getbalance(name user)
void hddpool::getbalance(name user)
{
//require_auth( user );
//require_auth(_self);
//require_auth2(user.value, "active"_n);
userhdd_index _userhdd(_self, _self.value);
userhdd_index _userhdd(_self, _self);
auto it = _userhdd.find(user.value);
if(it == _userhdd.end()){
_userhdd.emplace(_self, [&](auto &row) {
......@@ -78,8 +81,8 @@ ACTION hddpool::getbalance(name user)
else {
_userhdd.modify(it, _self, [&](auto &row) {
uint64_t tmp_t = current_time();
uint64_t tmp_last_balance = it->hdd_balance;
uint64_t new_balance;
int64_t tmp_last_balance = it->hdd_balance;
int64_t new_balance;
if(calculate_balance(tmp_last_balance, it->hdd_per_cycle_fee, it->hdd_per_cycle_profit, it->last_hdd_time, tmp_t, new_balance)) {
row.hdd_balance = new_balance;
row.last_hdd_time = tmp_t;
......@@ -89,7 +92,7 @@ ACTION hddpool::getbalance(name user)
}
}
bool hddpool::calculate_balance(uint64_t oldbalance, uint64_t hdd_per_cycle_fee, uint64_t hdd_per_cycle_profit, uint64_t last_hdd_time, uint64_t current_time, uint64_t &new_balance) {
bool hddpool::calculate_balance(int64_t oldbalance, int64_t hdd_per_cycle_fee, int64_t hdd_per_cycle_profit, uint64_t last_hdd_time, uint64_t current_time, int64_t &new_balance) {
uint64_t slot_t = (current_time - last_hdd_time)/1000000ll; //convert to seconds
new_balance = 0;
//print( "oldbalance: ", oldbalance, "\n" );
......@@ -100,16 +103,16 @@ bool hddpool::calculate_balance(uint64_t oldbalance, uint64_t hdd_per_cycle_fee,
//double delta = (int64_t)(((double)slot_t / (double)fee_cycle) * ( (int64_t)hdd_per_cycle_profit - (int64_t)hdd_per_cycle_fee ));
//print( "delta: ", (int64_t)delta, "\n" );
double tick = (double)(slot_t / fee_cycle);
double tick = (double)((double)slot_t/fee_cycle);
//if(tick == 0)
// return false;
int64_t delta = tick * (int64_t)(hdd_per_cycle_profit - hdd_per_cycle_fee );
new_balance = oldbalance + delta;
if(delta < 0 )
if(oldbalance <= (uint64_t)(-delta))
new_balance = 0;
new_balance = oldbalance;
int64_t delta = (int64_t)(tick * (hdd_per_cycle_profit - hdd_per_cycle_fee ));
if(delta < 0 && oldbalance <= -delta)
new_balance = 0;
else
new_balance += delta;
//print( "new_balance: ", new_balance, "\n" );
return true;
......@@ -126,7 +129,12 @@ void hddpool::update_hddofficial( userhdd_index& _hbalance, const int64_t _balan
row.hdd_balance = inc_hdd_amount;
row.hdd_per_cycle_fee = _fee;
row.hdd_per_cycle_profit = _profit;
row.hdd_space = _space;
if(_space >= 0)
row.hdd_space = (uint64_t)_space;
else
row.hdd_space = (uint64_t)(-_space);
row.last_hdd_time = current_time();
});
......@@ -136,8 +144,8 @@ void hddpool::update_hddofficial( userhdd_index& _hbalance, const int64_t _balan
row.hdd_balance += _balance;
if(_fee != 0 || _profit != 0) {
uint64_t tmp_t = current_time();
uint64_t tmp_last_balance = hbalance_itr->hdd_balance;
uint64_t new_balance;
int64_t tmp_last_balance = hbalance_itr->hdd_balance;
int64_t new_balance;
if(calculate_balance(tmp_last_balance, hbalance_itr->hdd_per_cycle_fee, hbalance_itr->hdd_per_cycle_profit, hbalance_itr->last_hdd_time, tmp_t, new_balance)) {
row.hdd_balance = new_balance;
row.last_hdd_time = tmp_t;
......@@ -145,37 +153,39 @@ void hddpool::update_hddofficial( userhdd_index& _hbalance, const int64_t _balan
}
row.hdd_per_cycle_fee += _fee;
row.hdd_per_cycle_profit += _profit;
row.hdd_space += _space;
if(_space >= 0)
row.hdd_space += (uint64_t)_space;
else
row.hdd_space -= (uint64_t)(-_space);
});
}
}
ACTION hddpool::buyhdd( name user , asset quant)
void hddpool::buyhdd( name user , asset quant)
{
require_auth( user );
eosio_assert(is_account(user), "user not a account");
eosio_assert(is_account(hdd_account), "to not a account");
eosio_assert(quant.is_valid(), "asset is invalid");
eosio_assert(quant.symbol == yta_symbol, "must use YTA to buy HDD");
eosio_assert(quant.symbol == CORE_SYMBOL, "must use YTA to buy HDD");
eosio_assert(quant.amount > 0, "must transfer positive quantity");
print( "quant.amount: ", quant.amount , "\n" );
/*
action(
permission_level{user, active_permission},
"eosio.token"_n, "transfer"_n,
token_account, N(transfer),
std::make_tuple(user, hdd_account, quant, std::string("buy hdd"))
).send();*/
).send();
uint64_t _hdd_amount = quant.amount * 10000;
userhdd_index _userhdd(_self, _self.value);
int64_t _hdd_amount = quant.amount * 10000;
userhdd_index _userhdd(_self, _self);
auto it = _userhdd.find(user.value);
if(it == _userhdd.end()){
_userhdd.emplace(_self, [&](auto &row) {
row.account_name = user;
//row.hdd_balance = _hdd_amount;
row.hdd_balance = inc_hdd_amount;
row.hdd_balance = _hdd_amount;
//row.hdd_balance = inc_hdd_amount;
row.hdd_per_cycle_fee = 0;
row.hdd_per_cycle_profit = 0;
row.hdd_space = 0;
......@@ -184,62 +194,61 @@ ACTION hddpool::buyhdd( name user , asset quant)
}
else {
_userhdd.modify(it, _self, [&](auto &row) {
//row.hdd_balance += _hdd_amount;
row.hdd_balance += inc_hdd_amount;
row.hdd_balance += _hdd_amount;
//row.hdd_balance += inc_hdd_amount;
});
}
//update_hddofficial(_userhdd, _hdd_amount , 0, 0, 0);
update_hddofficial(_userhdd, inc_hdd_amount , 0, 0, 0);
update_hddofficial(_userhdd, _hdd_amount , 0, 0, 0);
//update_hddofficial(_userhdd, inc_hdd_amount , 0, 0, 0);
}
ACTION hddpool::sellhdd (name user, int64_t amount)
void hddpool::sellhdd (name user, int64_t amount)
{
require_auth( user );
userhdd_index _userhdd(_self, _self.value);
userhdd_index _userhdd(_self, _self);
auto it = _userhdd.find(user.value);
eosio_assert( it != _userhdd.end(), "user not exists in userhdd table" );
eosio_assert( it != _userhdd.end(), "user not exists in userhdd table." );
eosio_assert( it->hdd_balance >= amount, "hdd overdrawn." );
_userhdd.modify(it, _self, [&](auto &row) {
//row.hdd_balance -= amount;
row.hdd_balance -= inc_hdd_amount;
row.hdd_balance -= amount;
//row.hdd_balance -= inc_hdd_amount;
});
uint64_t _yta_amount = (double)amount/10000;
/*
int64_t _yta_amount = (int64_t)((double)amount/10000);
asset quant{_yta_amount, yta_symbol};
asset quant{_yta_amount, CORE_SYMBOL};
action(
permission_level{hdd_account, active_permission},
"eosio.token"_n, "transfer"_n,
token_account, N(transfer),
std::make_tuple(hdd_account, user, quant, std::string("sell hdd"))
).send();
*/
//update_hddofficial(_userhdd, -amount , 0, 0, 0);
update_hddofficial(_userhdd, -inc_hdd_amount , 0, 0, 0);
update_hddofficial(_userhdd, -amount , 0, 0, 0);
//update_hddofficial(_userhdd, -inc_hdd_amount , 0, 0, 0);
}
ACTION hddpool::sethfee( name user, uint64_t fee)
void hddpool::sethfee( name user, int64_t fee)
{
eosio_assert(is_account(user), "user invalidate");
userhdd_index _userhdd(_self, _self.value);
userhdd_index _userhdd(_self, _self);
auto it = _userhdd.find(user.value);
eosio_assert( it != _userhdd.end(), "user not exists in userhdd table" );
eosio_assert(fee != it->hdd_per_cycle_fee, " the fee is the same \n");
//每周期费用 <= (占用存储空间*数据分片大小/1GB)*(记账周期/ 1年)
bool istrue = fee <= (uint64_t)(((double)(it->hdd_space * data_slice_size)/(double)one_gb) * ((double)fee_cycle/(double)seconds_in_one_year));
//每周期费用 <= (占用存储空间*数据分片大小/1GB)*(记账周期/ 1年)
//bool istrue = fee <= (int64_t)(((double)(it->hdd_space * data_slice_size)/(double)one_gb) * ((double)fee_cycle/(double)seconds_in_one_year));
//eosio_assert(istrue , "the fee verification is not right \n");
int64_t delta_fee = 0;
_userhdd.modify(it, _self, [&](auto &row) {
//设置每周期费用之前可能需要将以前的余额做一次计算,然后更改last_hdd_time
uint64_t tmp_t = current_time();
uint64_t tmp_last_balance = it->hdd_balance;
uint64_t new_balance;
int64_t tmp_last_balance = it->hdd_balance;
int64_t new_balance;
if(calculate_balance(tmp_last_balance, it->hdd_per_cycle_fee, it->hdd_per_cycle_profit, it->last_hdd_time, tmp_t, new_balance)) {
row.hdd_balance = new_balance;
row.last_hdd_time = tmp_t;
......@@ -252,12 +261,12 @@ ACTION hddpool::sethfee( name user, uint64_t fee)
update_hddofficial(_userhdd, 0, delta_fee, 0, 0);
}
ACTION hddpool::subbalance ( name user, uint64_t balance)
void hddpool::subbalance ( name user, int64_t balance)
{
//reuqire_auth(user);
require_auth(user);
eosio_assert(is_account(user), "user invalidate");
userhdd_index _userhdd(_self, _self.value);
userhdd_index _userhdd(_self, _self);
auto it = _userhdd.find(user.value);
eosio_assert( it != _userhdd.end(), "user not exists in userhdd table" );
......@@ -269,10 +278,10 @@ ACTION hddpool::subbalance ( name user, uint64_t balance)
}
ACTION hddpool::addhspace(name user, uint64_t space)
void hddpool::addhspace(name user, uint64_t space)
{
eosio_assert(is_account(user), "user invalidate");
userhdd_index _userhdd(_self, _self.value);
userhdd_index _userhdd(_self, _self);
auto it = _userhdd.find(user.value);
eosio_assert( it != _userhdd.end(), "user not exists in userhdd table" );
......@@ -280,13 +289,13 @@ ACTION hddpool::addhspace(name user, uint64_t space)
row.hdd_space += space;
});
update_hddofficial(_userhdd, 0, 0, 0, space);
update_hddofficial(_userhdd, 0, 0, 0, (int64_t)space);
}
ACTION hddpool::subhspace(name user, uint64_t space)
void hddpool::subhspace(name user, uint64_t space)
{
eosio_assert(is_account(user), "user invalidate");
userhdd_index _userhdd(_self, _self.value);
userhdd_index _userhdd(_self, _self);
auto it = _userhdd.find(user.value);
eosio_assert( it != _userhdd.end(), "user not exists in userhdd table" );
......@@ -294,14 +303,14 @@ ACTION hddpool::subhspace(name user, uint64_t space)
row.hdd_space -= space;
});
update_hddofficial(_userhdd, 0, 0, 0, (-1 * space));
update_hddofficial(_userhdd, 0, 0, 0, (int64_t)(-space));
}
ACTION hddpool::newmaccount(name owner, uint64_t minerid)
void hddpool::newmaccount(name owner, uint64_t minerid)
{
eosio_assert(is_account(owner), "owner invalidate");
maccount_index _maccount(_self, _self.value);
maccount_index _maccount(_self, _self);
auto it = _maccount.find(owner.value);
eosio_assert( it == _maccount.end(), "minerid already exist in maccount table \n" );
......@@ -310,7 +319,7 @@ ACTION hddpool::newmaccount(name owner, uint64_t minerid)
row.owner = owner;
});
userhdd_index _userhdd(_self, _self.value);
userhdd_index _userhdd(_self, _self);
auto userhdd_itr = _userhdd.find(owner.value);
if(userhdd_itr == _userhdd.end()) {
_userhdd.emplace(_self, [&](auto &row) {
......@@ -324,9 +333,9 @@ ACTION hddpool::newmaccount(name owner, uint64_t minerid)
}
}
ACTION hddpool::addmprofit(uint64_t minderid, uint64_t space)
void hddpool::addmprofit(uint64_t minderid, uint64_t space)
{
maccount_index _maccount(_self, _self.value);
maccount_index _maccount(_self, _self);
auto it = _maccount.find(minderid);
eosio_assert( it != _maccount.end(), "minerid not register \n" );
name owner = it->owner;
......@@ -335,21 +344,21 @@ ACTION hddpool::addmprofit(uint64_t minderid, uint64_t space)
});
//计算owner的每周期收益,计算之间先计算一下该用户上次的HDD余额
userhdd_index _userhdd(_self, _self.value);
userhdd_index _userhdd(_self, _self);
auto userhdd_itr = _userhdd.find(owner.value);
eosio_assert( userhdd_itr != _userhdd.end(), "no owner exists in userhdd table" );
int64_t delta_profit = 0;
_userhdd.modify(userhdd_itr, _self, [&](auto &row) {
uint64_t tmp_t = current_time();
uint64_t tmp_last_balance = userhdd_itr->hdd_balance;
uint64_t new_balance;
int64_t tmp_last_balance = userhdd_itr->hdd_balance;
int64_t new_balance;
if(calculate_balance(tmp_last_balance, userhdd_itr->hdd_per_cycle_fee, userhdd_itr->hdd_per_cycle_profit, userhdd_itr->last_hdd_time, tmp_t, new_balance)) {
row.hdd_balance = new_balance;
row.last_hdd_time = tmp_t;
}
uint64_t profit = 0;
int64_t profit = 0;
//每周期收益 += (生产空间*数据分片大小/1GB)*(记账周期/ 1年)
profit = (uint64_t)(((double)(space*data_slice_size)/(double)one_gb) * ((double)fee_cycle / (double)seconds_in_one_year));
profit = (int64_t)(((double)(space*data_slice_size)/(double)one_gb) * ((double)fee_cycle / (double)seconds_in_one_year));
delta_profit = profit - userhdd_itr->hdd_per_cycle_profit;
row.hdd_per_cycle_profit = profit;
});
......@@ -358,13 +367,13 @@ ACTION hddpool::addmprofit(uint64_t minderid, uint64_t space)
update_hddofficial(_userhdd, 0, 0, delta_profit, 0);
}
ACTION hddpool::clearall()
void hddpool::clearall()
{
userhdd_index _userhdd( _self , _self.value );
userhdd_index _userhdd( _self , _self );
while (_userhdd.begin() != _userhdd.end())
_userhdd.erase(_userhdd.begin());
maccount_index _maccount( _self , _self.value );
maccount_index _maccount( _self , _self );
while (_maccount.begin() != _maccount.end())
_maccount.erase(_maccount.begin());
......@@ -373,14 +382,14 @@ ACTION hddpool::clearall()
bool hddpool::is_bp_account(uint64_t uservalue)
{
capi_name producers[21];
uint32_t bytes_populated = get_active_producers(producers, sizeof(capi_name)*21);
uint32_t count = bytes_populated/sizeof(capi_name);
for(int i = 0 ; i <count; i++ ) {
account_name producers[21];
uint32_t bytes_populated = get_active_producers(producers, sizeof(account_name)*21);
uint32_t count = bytes_populated/sizeof(account_name);
for(uint32_t i = 0 ; i < count; i++ ) {
if(producers[i] == uservalue)
return true;
}
return false;
}
EOSIO_DISPATCH(hddpool, (getbalance)(buyhdd)(sellhdd)(sethfee)(subbalance)(addhspace)(subhspace)(newmaccount)(addmprofit)(clearall))
EOSIO_ABI( hddpool, (getbalance)(buyhdd)(sellhdd)(sethfee)(subbalance)(addhspace)(subhspace)(newmaccount)(addmprofit)(clearall))
#include <eosiolib/eosio.hpp>
#include <eosiolib/asset.hpp>
#include <eosiolib/time.hpp>
#include <eosiolib/singleton.hpp>
using eosio::contract;
using eosio::name;
using eosio::asset;
using eosio::symbol_type;
using eosio::indexed_by;
using eosio::const_mem_fun;
using eosio::microseconds;
using eosio::datastream;
using eosio::multi_index;
typedef double real_type;
using namespace eosio;
using namespace std;
CONTRACT hddpool : public contract {
class hddpool : public contract {
public:
using contract::contract;
hddpool( name s, name code, datastream<const char*> ds );
hddpool( account_name s);
~hddpool();
ACTION getbalance( name user );
ACTION buyhdd( name user , asset quant);
ACTION sellhdd( name user, int64_t mount);
ACTION sethfee( name user, uint64_t fee);
ACTION subbalance ( name user, uint64_t balance);
ACTION addhspace(name user, uint64_t space);
ACTION subhspace(name user, uint64_t space);
ACTION newmaccount(name owner, uint64_t minerid);
ACTION addmprofit(uint64_t minderid, uint64_t space);
ACTION clearall();
// accessor for external contracts to easily send inline actions to your contract
using getbalance_action = action_wrapper<"getbalance"_n, &hddpool::getbalance>;
using buyhdd_action = action_wrapper<"buyhdd"_n, &hddpool::buyhdd>;
using sellhdd_action = action_wrapper<"sellhdd"_n, &hddpool::sellhdd>;
using sethfee_action = action_wrapper<"sethfee"_n, &hddpool::sethfee>;
using subbalance_action = action_wrapper<"subbalance"_n, &hddpool::subbalance>;
using addhspace_action = action_wrapper<"addhspace"_n, &hddpool::addhspace>;
using subhspace_action = action_wrapper<"subhspace"_n, &hddpool::subhspace>;
using newmaccount_action = action_wrapper<"newmaccount"_n, &hddpool::newmaccount>;
using addmprofit_action = action_wrapper<"addmprofit"_n, &hddpool::addmprofit>;
using clearall_action = action_wrapper<"clearall"_n, &hddpool::clearall>;
void getbalance( name user );
void buyhdd( name user , asset quant);
void sellhdd( name user, int64_t amount);
void sethfee( name user, int64_t fee);
void subbalance ( name user, int64_t balance);
void addhspace(name user, uint64_t space);
void subhspace(name user, uint64_t space);
void newmaccount(name owner, uint64_t minerid);
void addmprofit(uint64_t minderid, uint64_t space);
void clearall();
private:
TABLE userhdd {
struct userhdd {
name account_name; //账户名
uint64_t hdd_balance; //余额
uint64_t hdd_per_cycle_fee; //每周期费用
uint64_t hdd_per_cycle_profit; //每周期收益
int64_t hdd_balance; //余额
int64_t hdd_per_cycle_fee; //每周期费用
int64_t hdd_per_cycle_profit; //每周期收益
uint64_t hdd_space; //占用存储空间
uint64_t last_hdd_time; //上次余额计算时间 microseconds from 1970
uint64_t primary_key() const { return account_name.value; }
uint64_t primary_key() const { return account_name.value; }
};
typedef multi_index<N(userhdd), userhdd> userhdd_index;
TABLE maccount {
struct maccount {
uint64_t minerid; //矿机id
name owner; //拥有矿机的矿主的账户名
uint64_t space; //生产空间
uint64_t primary_key() const { return minerid; }
//uint64_t get_owner() const { return owner.value; }
};
typedef multi_index< N(maccount), maccount > maccount_index;
struct [[eosio::table("hddglobal"), eosio::contract("hddpool")]] hdd_global_state {
uint64_t hdd_total_balance = 0;
};
struct hdd_global_state {
int64_t hdd_total_balance = 0;
};
typedef eosio::multi_index< "userhdd"_n, userhdd > userhdd_index;
typedef eosio::multi_index< "maccount"_n, maccount > maccount_index;
typedef eosio::singleton<"hddglobal"_n, hdd_global_state> global_state_singleton;
typedef eosio::singleton<N(hddglobal), hdd_global_state> global_state_singleton;
global_state_singleton _global;
hdd_global_state _gstate;
......@@ -72,9 +69,9 @@ CONTRACT hddpool : public contract {
static hdd_global_state get_default_param();
bool calculate_balance(uint64_t oldbalance, uint64_t hdd_per_cycle_fee,
uint64_t hdd_per_cycle_profit, uint64_t last_hdd_time, uint64_t current_time,
uint64_t &new_balance);
bool calculate_balance(int64_t oldbalance, int64_t hdd_per_cycle_fee,
int64_t hdd_per_cycle_profit, uint64_t last_hdd_time, uint64_t current_time,
int64_t &new_balance);
void update_hddofficial( userhdd_index& _hbalance, const int64_t _balance,
const int64_t _fee, const int64_t _profit,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册