提交 eb134438 编写于 作者: W Wang Zhi

remove hdddata.

hdddata will replcate by hddpool
上级 8f47ae94
file(GLOB ABI_FILES "*.abi")
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
add_wast_executable(TARGET hdddata
INCLUDE_FOLDERS ${STANDARD_INCLUDE_FOLDERS}
LIBRARIES libc++ libc eosiolib eosio.token
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR}
)
{
"version": "eosio::abi/1.0",
"structs": [
{
"name": "addhspace",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "hddaccount",
"type": "name"
},
{
"name": "space",
"type": "uint64"
}
]
},
{
"name": "addmprofit",
"base": "",
"fields": [
{
"name": "mname",
"type": "name"
},
{
"name": "space",
"type": "uint64"
}
]
},
{
"name": "buyhdd",
"base": "",
"fields": [
{
"name": "buyer",
"type": "name"
},
{
"name": "receiver",
"type": "name"
},
{
"name": "quant",
"type": "asset"
}
]
},
{
"name": "connector",
"base": "",
"fields": [
{
"name": "balance",
"type": "asset"
},
{
"name": "weight",
"type": "float64"
}
]
},
{
"name": "exchange_state",
"base": "",
"fields": [
{
"name": "supply",
"type": "asset"
},
{
"name": "base",
"type": "connector"
},
{
"name": "quote",
"type": "connector"
}
]
},
{
"name": "gethbalance",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
}
]
},
{
"name": "gethsum",
"base": "",
"fields": []
},
{
"name": "hbalance",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "last_hdd_balance",
"type": "uint64"
},
{
"name": "hdd_per_cycle_fee",
"type": "uint64"
},
{
"name": "hdd_per_cycle_profit",
"type": "uint64"
},
{
"name": "hdd_space",
"type": "uint64"
},
{
"name": "last_hdd_time",
"type": "uint64"
}
]
},
{
"name": "maccount",
"base": "",
"fields": [
{
"name": "ming_id",
"type": "uint64"
},
{
"name": "owner",
"type": "name"
}
]
},
{
"name": "newmaccount",
"base": "",
"fields": [
{
"name": "mname",
"type": "name"
},
{
"name": "owner",
"type": "name"
}
]
},
{
"name": "producer",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "producer_key",
"type": "name"
}
]
},
{
"name": "sellhdd",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "quant",
"type": "uint64"
}
]
},
{
"name": "sethfee",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "fee",
"type": "uint64"
}
]
},
{
"name": "subhbalance",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "balance",
"type": "uint64"
}
]
},
{
"name": "subhspace",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "hddaccount",
"type": "name"
},
{
"name": "space",
"type": "uint64"
}
]
}
],
"types": [],
"actions": [
{
"name": "addhspace",
"type": "addhspace",
"ricardian_contract": ""
},
{
"name": "addmprofit",
"type": "addmprofit",
"ricardian_contract": ""
},
{
"name": "buyhdd",
"type": "buyhdd",
"ricardian_contract": ""
},
{
"name": "gethbalance",
"type": "gethbalance",
"ricardian_contract": ""
},
{
"name": "gethsum",
"type": "gethsum",
"ricardian_contract": ""
},
{
"name": "newmaccount",
"type": "newmaccount",
"ricardian_contract": ""
},
{
"name": "sellhdd",
"type": "sellhdd",
"ricardian_contract": ""
},
{
"name": "sethfee",
"type": "sethfee",
"ricardian_contract": ""
},
{
"name": "subhbalance",
"type": "subhbalance",
"ricardian_contract": ""
},
{
"name": "subhspace",
"type": "subhspace",
"ricardian_contract": ""
}
],
"tables": [
{
"name": "hbalance",
"type": "hbalance",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "hmarket",
"type": "exchange_state",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "maccount",
"type": "maccount",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "producer",
"type": "producer",
"index_type": "i64",
"key_names": [],
"key_types": []
}
],
"ricardian_clauses": [],
"abi_extensions": []
}
\ No newline at end of file
#include "hdddata.hpp"
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/serialize.hpp>
#include <eosiolib/multi_index.hpp>
#include <eosio.token/eosio.token.hpp>
#include <cmath>
#include <string>
#include <type_traits>
#include <optional>
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_year = seconds_in_one_day * 365;
const int64_t useconds_per_day = 24 * 3600 * int64_t(1000000);
const uint32_t one_gb = 1024*1024*1024; //1GB
const uint32_t data_slice_size = 8*1024; // among 4k-32k,set it as 8k
const uint32_t preprocure_space = one_gb; // set as 1G
const name HDD_OFFICIAL = name{N(hddofficial)};
// constructor
hdddata::hdddata( account_name s )
: eosio::contract(s),
_maccount(_self, _self),
_hmarket(_self, _self),
_producer(_self, _self) {
auto itr = _hmarket.find(S(4,HDDCORE));
if( itr == _hmarket.end() ) {
auto system_token_supply = eosio::token(N(eosio.token)).get_supply(eosio::symbol_type(CORE_SYMBOL).name()).amount;
if( system_token_supply > 0 ) {
itr = _hmarket.emplace( _self, [&]( auto& m ) {
m.supply.amount = 100000000000000ll;
m.supply.symbol = S(4,HDDCORE);
m.base.balance.amount = 1024ll*1024*1024*1024*1024;
m.base.balance.symbol = S(0,HDD);
m.quote.balance.amount = system_token_supply / 1000;
m.quote.balance.symbol = CORE_SYMBOL;
});
}
} else {
//print( "ram market already created" );
}
}
/*
hdddata::hdddata( account_name s )
: contract(s)
{
}
*/
hdddata:: ~hdddata() {
}
/*
symbol hdddata::core_symbol()const {
const static auto sym = get_core_symbol( _hmarket );
return sym;
}
*/
/*
//@abit action
void hdddata::init(name owner) {
require_auth( owner );
hbalance_table _hbalance(_self, _self.value);
auto hbalance_itr = _hbalance.find(owner.value);
eosio_assert( hbalance_itr == _hbalance.end(), "_hbalance table has already been initialized" );
_hbalance.emplace(_self, [&](auto &row) {
//todo check the 1st time insert
row.owner = owner;
row.last_hdd_balance=10;
row.hdd_per_cycle_fee=10;
row.hdd_per_cycle_profit=10;
row.hdd_space=20;
row.last_hdd_time = current_time();
});
auto itr = _hmarket.find(hddcore_symbol.raw());
eosio_assert( itr == _hmarket.end(), "_hmarket has already been initialized" );
auto system_token_supply = eosio::token::get_supply(token_account, yta_symbol.code() );
eosio_assert( system_token_supply.symbol == yta_symbol, "specified core symbol does not exist (precision mismatch)" );
eosio_assert( system_token_supply.amount > 0, "system token supply must be greater than 0" );
_hmarket.emplace( _self, [&]( auto& m ) {
m.supply.amount = 100000000000000ll;
m.supply.symbol = hddcore_symbol;
m.base.balance.amount = 1024ll*1024*1024*1024*1024;
m.base.balance.symbol = hdd_symbol;
m.quote.balance.amount = system_token_supply.amount / 1000;
m.quote.balance.symbol = yta_symbol;
});
}
*/
//@abi action
void hdddata::gethbalance(name owner) {
require_auth(owner);
hbalance_table _hbalance(_self, _self);
auto hbalance_itr = _hbalance.find(owner.value);
if(hbalance_itr == _hbalance.end()) {
_hbalance.emplace(owner, [&](auto &row) {
print("A gethbalance : ", owner, " is new ... \n");
row.owner = owner;
row.last_hdd_balance=10;
row.hdd_per_cycle_fee=5;
row.hdd_per_cycle_profit=10;
row.hdd_space=10;
row.last_hdd_time = current_time();
});
} else {
uint64_t tmp_t = current_time();
_hbalance.modify(hbalance_itr, _self, [&](auto &row) {
print("gethbalance modify last_hdd_balance : ", hbalance_itr->get_last_hdd_balance(), "\n");
uint64_t slot_t = (tmp_t - hbalance_itr->last_hdd_time)/1000000ll; //convert to seconds
print("gethbalance modify slot_t : ", slot_t, "\n");
//todo check overflow and time cycle
row.last_hdd_balance=
hbalance_itr->get_last_hdd_balance() +
slot_t * ( hbalance_itr->get_hdd_per_cycle_profit() - hbalance_itr->get_hdd_per_cycle_fee() ) * seconds_in_one_day;
print("B gethbalance .last_hdd_balance : ", row.last_hdd_balance, "\n");
row.last_hdd_time = tmp_t;
});
}
}
void hdddata::update_hddofficial(hbalance_table& _hbalance, const uint64_t _hb, const uint64_t time) {
auto hbalance_itr = _hbalance.find(HDD_OFFICIAL.value);
eosio_assert( hbalance_itr != _hbalance.end(), "no HDD_OFFICIAL exists in hbalance table" );
_hbalance.modify(hbalance_itr, _self, [&](auto &row) {
//todo check overflow and time cycle
row.last_hdd_balance += _hb;
row.last_hdd_time = time;
});
}
void hdddata::gethsum() {
require_auth(_self);
hbalance_table _hbalance(_self, _self);
auto hbalance_itr = _hbalance.find(HDD_OFFICIAL.value);
eosio_assert( hbalance_itr != _hbalance.end(), "no HDD_OFFICIAL exists in hbalance table" );
//todo check the 1st time insert
uint64_t tmp_t = current_time();
_hbalance.modify(hbalance_itr, _self, [&](auto &row) {
print("gethbalance modify last_hdd_balance : ", hbalance_itr->get_last_hdd_balance(), "\n");
uint64_t slot_t = (tmp_t - hbalance_itr->last_hdd_time)/1000000ll; //convert to seconds
print("gethbalance modify slot_t : ", slot_t, "\n");
//todo check overflow and time cycle
row.last_hdd_balance=
hbalance_itr->get_last_hdd_balance() +
slot_t * ( hbalance_itr->get_hdd_per_cycle_profit() - hbalance_itr->get_hdd_per_cycle_fee() ) * seconds_in_one_day;
print("B gethbalance .last_hdd_balance : ", row.last_hdd_balance, "\n");
row.last_hdd_time = tmp_t;
});
}
//@abi action
void hdddata::sethfee(name owner, uint64_t fee) {
require_auth(_self);
require_auth(owner);
hbalance_table _hbalance(owner, owner.value);
auto hbalance_itr = _hbalance.find(owner.value);
eosio_assert( hbalance_itr != _hbalance.end(), "no owner exists in _hbalance table" );
//每周期费用 <= (占用存储空间*数据分片大小/1GB)*(记账周期/ 1年)
//eos_assert( xxx, "");
_hbalance.modify(hbalance_itr, owner, [&](auto &row) {
print("A row.hdd_per_cycle_fee : ", row.hdd_per_cycle_fee, " \n");
//todo check overflow
row.hdd_per_cycle_fee -=fee;
});
print("B row.hdd_per_cycle_fee : ", hbalance_itr->get_hdd_per_cycle_fee(), " \n");
//每周期费用 <= (占用存储空间*数据分片大小/1GB)*(记账周期/ 1年)
}
//@abi action
void hdddata::subhbalance(name owner, uint64_t balance){
require_auth(_self);
require_auth(owner);
hbalance_table _hbalance(_self, _self);
auto hbalance_itr = _hbalance.find(owner.value);
eosio_assert( hbalance_itr != _hbalance.end(), "no owner exists in _hbalance table" );
_hbalance.modify(hbalance_itr, owner, [&](auto &row) {
//todo check overflow
row.last_hdd_balance -=balance;
});
}
//@abi action
void hdddata::addhspace(name owner, name hddaccount, uint64_t space){
require_auth(owner);
require_auth(hddaccount);
hbalance_table _hbalance(_self, _self);
auto hbalance_itr = _hbalance.find(hddaccount.value);
eosio_assert( hbalance_itr != _hbalance.end(), "no owner exists in _hbalance table" );
_hbalance.modify(hbalance_itr, hddaccount, [&](auto &row) {
//todo check overflow
row.hdd_space +=space;
});
}
//@abi action
void hdddata::subhspace(name owner, name hddaccount, uint64_t space){
require_auth(owner);
require_auth(hddaccount);
hbalance_table _hbalance(_self, _self);
auto hbalance_itr = _hbalance.find(hddaccount.value);
eosio_assert( hbalance_itr != _hbalance.end(), "no owner exists in _hbalance table" );
_hbalance.modify(hbalance_itr, hddaccount, [&](auto &row) {
//todo check overflow
row.hdd_space -=space;
});
}
//@abi action
void hdddata::newmaccount(name mname, name owner) {
require_auth(mname);
//maccount_table _maccount(_self, _self.value);
auto maccount_itr = _maccount.find(mname.value);
eosio_assert( maccount_itr == _maccount.end(), "owner already exist in _maccount table \n" );
_maccount.emplace(mname, [&](auto &row) {
row.ming_id = mname.value;
row.owner = owner;
});
require_auth(owner);
hbalance_table _hbalance(_self, _self);
auto hbalance_itr = _hbalance.find(owner.value);
eosio_assert( hbalance_itr == _hbalance.end(), "no owner exists in _hbalance table" );
_hbalance.emplace(owner, [&](auto &row) {
//todo check the 1st time insert to modify
row.owner = owner;
row.last_hdd_balance=10;
row.hdd_per_cycle_fee=10;
row.hdd_per_cycle_profit=10;
row.hdd_space=0;
row.last_hdd_time=current_time();
});
}
//@abi action
void hdddata::addmprofit(name mname, uint64_t space){
require_auth(mname);
//maccount_table _maccount(_self, _self.value);
auto maccount_itr = _maccount.find(mname.value);
eosio_assert( maccount_itr != _maccount.end(), "no owner exists in _hbalance table" );
hbalance_table _hbalance(_self, _self);
auto owner_id = maccount_itr->get_owner();
auto hbalance_itr = _hbalance.find(owner_id);
eosio_assert( hbalance_itr == _hbalance.end(), "no owner exists in _hbalance table" );
//space verification
eosio_assert(hbalance_itr->get_hdd_space()+ data_slice_size ==space , "not correct verification");
_hbalance.modify(hbalance_itr, _self, [&](auto &row) {
//todo check the 1st time insert
//row.owner = owner;
row.hdd_space += data_slice_size;
row.hdd_per_cycle_profit += (preprocure_space*data_slice_size/one_gb);
});
//每周期收益 += (预采购空间*数据分片大小/1GB)*(记账周期/ 1年)
}
//@abi action
void hdddata::buyhdd(name buyer, name receiver, asset quant) {
require_auth(buyer);
eosio_assert( quant.amount > 0, "must purchase a positive amount" );
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {buyer,N(active)},
{ buyer, N(eosio.hdd), quant, std::string("buy hdd") } );
int64_t bytes_out;
const auto& market = _hmarket.get(S(4,HDDCORE), "hdd market does not exist");
_hmarket.modify( market, 0, [&]( auto& es ) {
bytes_out = es.convert( quant, S(0,HDD)).amount;
});
print("bytes_out: ", bytes_out, "\n");
eosio_assert( bytes_out > 0, "must reserve a positive amount" );
hbalance_table _hbalance(_self, _self);
auto res_itr = _hbalance.find( receiver.value );
if( res_itr == _hbalance.end() ) {
res_itr = _hbalance.emplace( receiver, [&]( auto& res ) {
res.owner = receiver;
res.last_hdd_balance = bytes_out;
res.last_hdd_time = current_time();
});
} else {
_hbalance.modify( res_itr, receiver, [&]( auto& res ) {
res.last_hdd_balance += bytes_out;
res.last_hdd_time = current_time();
});
}
}
//@abi action
void hdddata::sellhdd(name account, uint64_t quant){
require_auth(account);
eosio_assert( quant > 0, "cannot sell negative hdd" );
hbalance_table _hbalance(_self, _self);
auto res_itr = _hbalance.find( account.value );
eosio_assert( res_itr != _hbalance.end(), "no resource row" );
//need to calculate the latest hddbalance
eosio_assert( res_itr->get_last_hdd_balance() >= quant, "insufficient hdd" );
asset tokens_out;
auto itr = _hmarket.find(S(4,HDDCORE));
_hmarket.modify( itr, 0, [&]( auto& es ) {
/// the cast to int64_t of quant is safe because we certify quant is <= quota which is limited by prior purchases
tokens_out = es.convert( asset(quant, S(0,HDD)), CORE_SYMBOL);
});
_hbalance.modify( res_itr, account, [&]( auto& res ) {
res.last_hdd_balance -= quant;
res.last_hdd_time = current_time();
});
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio.hdd),N(active)},
{ N(eosio.hdd), account, asset(tokens_out), std::string("sell hdd") } );
}
asset exchange_state::convert_to_exchange( connector& c, asset in ) {
real_type R(supply.amount);
real_type C(c.balance.amount+in.amount);
real_type F(c.weight/1000.0);
real_type T(in.amount);
real_type ONE(1.0);
real_type E = -R * (ONE - std::pow( ONE + T / C, F) );
//print( "E: ", E, "\n");
int64_t issued = int64_t(E);
supply.amount += issued;
c.balance.amount += in.amount;
return asset( issued, supply.symbol );
}
asset exchange_state::convert_from_exchange( connector& c, asset in ) {
eosio_assert( in.symbol== supply.symbol, "unexpected asset symbol input" );
real_type R(supply.amount - in.amount);
real_type C(c.balance.amount);
real_type F(1000.0/c.weight);
real_type E(in.amount);
real_type ONE(1.0);
// potentially more accurate:
// The functions std::expm1 and std::log1p are useful for financial calculations, for example,
// when calculating small daily interest rates: (1+x)n
// -1 can be expressed as std::expm1(n * std::log1p(x)).
// real_type T = C * std::expm1( F * std::log1p(E/R) );
real_type T = C * (std::pow( ONE + E/R, F) - ONE);
//print( "T: ", T, "\n");
int64_t out = int64_t(T);
supply.amount -= in.amount;
c.balance.amount -= out;
return asset( out, c.balance.symbol );
}
asset exchange_state::convert( asset from, symbol_type to ) {
auto sell_symbol = from.symbol;
auto ex_symbol = supply.symbol;
auto base_symbol = base.balance.symbol;
auto quote_symbol = quote.balance.symbol;
//print( "From: ", from, " TO ", asset( 0,to), "\n" );
//print( "base: ", base_symbol, "\n" );
//print( "quote: ", quote_symbol, "\n" );
//print( "ex: ", supply.symbol, "\n" );
if( sell_symbol != ex_symbol ) {
if( sell_symbol == base_symbol ) {
from = convert_to_exchange( base, from );
} else if( sell_symbol == quote_symbol ) {
from = convert_to_exchange( quote, from );
} else {
eosio_assert( false, "invalid sell" );
}
} else {
if( to == base_symbol ) {
from = convert_from_exchange( base, from );
} else if( to == quote_symbol ) {
from = convert_from_exchange( quote, from );
} else {
eosio_assert( false, "invalid conversion" );
}
}
if( to != from.symbol )
return convert( from, to );
return from;
}
EOSIO_ABI( hdddata, (gethbalance)(gethsum)(sethfee)(newmaccount)(addmprofit)(subhbalance)(buyhdd)(sellhdd)(addhspace)(subhspace))
/*
extern "C" {
void apply(uint64_t receiver, uint64_t code, uint64_t action) {
if(code==receiver)
{
switch(action)
{
EOSIO_DISPATCH_HELPER( hdddata, (gethbalance)(gethsum)(sethfee)(newmaccount)(addmprofit)(subhbalance)(buyhdd)(sellhdd)(addhspace)(subhspace) )
}
}
}
};
*/
#include <eosiolib/eosio.hpp>
#include <eosiolib/asset.hpp>
#include <eosiolib/time.hpp>
#include <eosiolib/singleton.hpp>
using namespace eosio;
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;
typedef double real_type;
//todo copy from eosio.system
/**
* Uses Bancor math to create a 50/50 relay between two asset types. The state of the
* bancor exchange is entirely contained within this struct. There are no external
* side effects associated with using this API.
*/
struct exchange_state {
asset supply;
struct connector {
asset balance;
double weight = .5;
EOSLIB_SERIALIZE( connector, (balance)(weight) )
};
connector base;
connector quote;
uint64_t primary_key()const { return supply.symbol; }
asset convert_to_exchange( connector& c, asset in );
asset convert_from_exchange( connector& c, asset in );
asset convert( asset from, symbol_type to );
EOSLIB_SERIALIZE( exchange_state, (supply)(base)(quote) )
};
//comment old style declaration
typedef multi_index<N(hmarket), exchange_state> hmarket_table;
class hdddata : public contract {
public:
using contract::contract;
hdddata( account_name s);
~hdddata();
void gethbalance(name owner);
void gethsum();
void sethfee(name owner, uint64_t fee);
void newmaccount(name mname, name owner);
void addmprofit(name mname, uint64_t space);
void subhbalance(name owner, uint64_t balance);
void buyhdd(name buyer, name receiver, asset quant);
void sellhdd(name account, uint64_t quant);
void addhspace(name owner, name hddaccount, uint64_t space);
void subhspace(name owner, name hddaccount, uint64_t space);
//static constexpr symbol hddcore_symbol = symbol(symbol_code("HDDCORE"), 4);
//static constexpr symbol hdd_symbol = symbol(symbol_code("HDD"), 0);
//static constexpr symbol yta_symbol = symbol(symbol_code("YTA"), 4);
//static constexpr eosio::name token_account{N(eosio.token)};
//static constexpr eosio::name hdd_account{N(eosio.hdd)};
//static constexpr eosio::name hddfee_account{N(eosio.hddfee)};
//static constexpr eosio::name active_permission{N(active)};
/*
static symbol get_core_symbol( name system_account = N(hddofficial) ) {
hmarket_table rm(system_account, system_account.value);
const static auto sym = get_core_symbol( rm );
return sym;
}
*/
private:
// Implementation details:
/*
static symbol get_core_symbol( const hmarket_table& hdd ) {
auto itr = hdd.find(hddcore_symbol.raw());
check(itr != hdd.end(), "system contract must first be initialized");
return itr->quote.balance.symbol;
}
symbol core_symbol() const;
*/
struct hbalance {
name owner = name{N(hddofficial)};
uint64_t last_hdd_balance=0;
uint64_t hdd_per_cycle_fee=0;
uint64_t hdd_per_cycle_profit=0;
uint64_t hdd_space=0;
uint64_t last_hdd_time = current_time(); //microseconds from 1970
uint64_t primary_key() const { return owner.value; }
uint64_t get_last_hdd_balance() const { return last_hdd_balance; }
uint64_t get_hdd_per_cycle_fee() const { return hdd_per_cycle_fee; }
uint64_t get_hdd_per_cycle_profit() const { return hdd_per_cycle_profit; }
uint64_t get_hdd_space() const { return hdd_space; }
};
typedef multi_index<N(hbalance), hbalance,
indexed_by<N(bybalance), const_mem_fun<hbalance, uint64_t, &hbalance::get_last_hdd_balance>>,
indexed_by<N(byfee), const_mem_fun<hbalance, uint64_t, &hbalance::get_hdd_per_cycle_fee>>,
indexed_by<N(byprofit), const_mem_fun<hbalance, uint64_t, &hbalance::get_hdd_per_cycle_profit>>,
indexed_by<N(byspace), const_mem_fun<hbalance, uint64_t, &hbalance::get_hdd_space>>>
hbalance_table;
// ming account
struct maccount {
uint64_t ming_id;
name owner;
uint64_t primary_key() const { return ming_id; }
uint64_t get_owner() const { return owner.value; }
};
typedef multi_index<N(maccount), maccount,
indexed_by<N(byowner), const_mem_fun<maccount, uint64_t, &maccount::get_owner>>>
maccount_table;
struct producer {
name owner;
name producer_key;
uint64_t primary_key() const { return owner.value; }
};
typedef multi_index<N(producer), producer> producer_table;
private:
void update_hddofficial(hbalance_table& _hblance, const uint64_t _hb, const uint64_t time);
//hbalance_table _hbalance;
maccount_table _maccount;
producer_table _producer;
hmarket_table _hmarket;
};
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册