Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
1d1ac19c
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,发现更多精彩内容 >>
提交
1d1ac19c
编写于
5月 05, 2019
作者:
W
Wang Zhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update hdddata for build problem
update hdddata for build problem
上级
217f0d03
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
197 addition
and
159 deletion
+197
-159
contracts/hdddata/CMakeLists.txt
contracts/hdddata/CMakeLists.txt
+8
-0
contracts/hdddata/hdddata.abi
contracts/hdddata/hdddata.abi
+2
-19
contracts/hdddata/hdddata.cpp
contracts/hdddata/hdddata.cpp
+132
-84
contracts/hdddata/hdddata.hpp
contracts/hdddata/hdddata.hpp
+55
-56
未找到文件。
contracts/hdddata/CMakeLists.txt
0 → 100644
浏览文件 @
1d1ac19c
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
}
)
contracts/hdddata/hdddata.abi
浏览文件 @
1d1ac19c
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT Wed Apr 17 02:07:54 2019",
"version": "eosio::abi/1.1",
"version": "eosio::abi/1.0",
"structs": [
{
"name": "addhspace",
...
...
@@ -129,16 +128,6 @@
}
]
},
{
"name": "init",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
}
]
},
{
"name": "maccount",
"base": "",
...
...
@@ -177,7 +166,7 @@
},
{
"name": "producer_key",
"type": "
public_key
"
"type": "
name
"
}
]
},
...
...
@@ -269,11 +258,6 @@
"type": "gethsum",
"ricardian_contract": ""
},
{
"name": "init",
"type": "init",
"ricardian_contract": ""
},
{
"name": "newmaccount",
"type": "newmaccount",
...
...
@@ -331,6 +315,5 @@
}
],
"ricardian_clauses": [],
"variants": [],
"abi_extensions": []
}
\ No newline at end of file
contracts/hdddata/hdddata.cpp
浏览文件 @
1d1ac19c
...
...
@@ -21,24 +21,56 @@ 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
=
"hddofficial"
_n
;
const
name
HDD_OFFICIAL
=
name
{
N
(
hddofficial
)}
;
// constructor
hdddata
::
hdddata
(
name
s
,
name
code
,
datastream
<
const
char
*>
ds
)
:
eosio
::
contract
(
s
,
code
,
ds
),
_maccount
(
_self
,
_self
.
value
),
_hmarket
(
_self
,
_self
.
value
),
_producer
(
_self
,
_self
.
value
)
{
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 );
...
...
@@ -77,10 +109,12 @@ void hdddata::init(name owner) {
});
}
*/
//@abi action
void
hdddata
::
gethbalance
(
name
owner
)
{
require_auth
(
owner
);
hbalance_table
_hbalance
(
_self
,
_self
.
value
);
hbalance_table
_hbalance
(
_self
,
_self
);
auto
hbalance_itr
=
_hbalance
.
find
(
owner
.
value
);
if
(
hbalance_itr
==
_hbalance
.
end
())
{
_hbalance
.
emplace
(
owner
,
[
&
](
auto
&
row
)
{
...
...
@@ -114,6 +148,7 @@ void hdddata::gethbalance(name owner) {
}
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"
);
...
...
@@ -126,7 +161,7 @@ void hdddata::update_hddofficial(hbalance_table& _hbalance, const uint64_t _hb,
void
hdddata
::
gethsum
()
{
require_auth
(
_self
);
hbalance_table
_hbalance
(
_self
,
_self
.
value
);
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
...
...
@@ -172,7 +207,7 @@ void hdddata::sethfee(name owner, uint64_t fee) {
void
hdddata
::
subhbalance
(
name
owner
,
uint64_t
balance
){
require_auth
(
_self
);
require_auth
(
owner
);
hbalance_table
_hbalance
(
_self
,
_self
.
value
);
hbalance_table
_hbalance
(
_self
,
_self
);
auto
hbalance_itr
=
_hbalance
.
find
(
owner
.
value
);
eosio_assert
(
hbalance_itr
!=
_hbalance
.
end
(),
"no owner exists in _hbalance table"
);
...
...
@@ -188,7 +223,7 @@ void hdddata::subhbalance(name owner, uint64_t balance){
void
hdddata
::
addhspace
(
name
owner
,
name
hddaccount
,
uint64_t
space
){
require_auth
(
owner
);
require_auth
(
hddaccount
);
hbalance_table
_hbalance
(
_self
,
_self
.
value
);
hbalance_table
_hbalance
(
_self
,
_self
);
auto
hbalance_itr
=
_hbalance
.
find
(
hddaccount
.
value
);
eosio_assert
(
hbalance_itr
!=
_hbalance
.
end
(),
"no owner exists in _hbalance table"
);
...
...
@@ -204,7 +239,7 @@ void hdddata::addhspace(name owner, name hddaccount, uint64_t space){
void
hdddata
::
subhspace
(
name
owner
,
name
hddaccount
,
uint64_t
space
){
require_auth
(
owner
);
require_auth
(
hddaccount
);
hbalance_table
_hbalance
(
_self
,
_self
.
value
);
hbalance_table
_hbalance
(
_self
,
_self
);
auto
hbalance_itr
=
_hbalance
.
find
(
hddaccount
.
value
);
eosio_assert
(
hbalance_itr
!=
_hbalance
.
end
(),
"no owner exists in _hbalance table"
);
...
...
@@ -220,6 +255,7 @@ void hdddata::subhspace(name owner, name hddaccount, uint64_t 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
"
);
...
...
@@ -230,7 +266,7 @@ void hdddata::newmaccount(name mname, name owner) {
});
require_auth
(
owner
);
hbalance_table
_hbalance
(
_self
,
_self
.
value
);
hbalance_table
_hbalance
(
_self
,
_self
);
auto
hbalance_itr
=
_hbalance
.
find
(
owner
.
value
);
eosio_assert
(
hbalance_itr
==
_hbalance
.
end
(),
"no owner exists in _hbalance table"
);
...
...
@@ -244,16 +280,18 @@ void hdddata::newmaccount(name mname, name owner) {
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
.
value
);
hbalance_table
_hbalance
(
_self
,
_self
);
auto
owner_id
=
maccount_itr
->
get_owner
();
auto
hbalance_itr
=
_hbalance
.
find
(
owner_id
);
...
...
@@ -269,26 +307,29 @@ void hdddata::addmprofit(name mname, uint64_t space){
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
)(
token_account
,
{
buyer
,
active_permission
},
{
buyer
,
hdd_account
,
quant
,
std
::
string
(
"buy hdd"
)
}
);
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
(
hddcore_symbol
.
raw
(
),
"hdd market does not exist"
);
_hmarket
.
modify
(
market
,
same_payer
,
[
&
](
auto
&
es
)
{
bytes_out
=
es
.
convert
(
quant
,
hdd_symbol
).
amount
;
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
.
value
);
hbalance_table
_hbalance
(
_self
,
_self
);
auto
res_itr
=
_hbalance
.
find
(
receiver
.
value
);
if
(
res_itr
==
_hbalance
.
end
()
)
{
res_itr
=
_hbalance
.
emplace
(
receiver
,
[
&
](
auto
&
res
)
{
...
...
@@ -302,13 +343,15 @@ void hdddata::buyhdd(name buyer, name receiver, asset quant) {
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
.
value
);
hbalance_table
_hbalance
(
_self
,
_self
);
auto
res_itr
=
_hbalance
.
find
(
account
.
value
);
eosio_assert
(
res_itr
!=
_hbalance
.
end
(),
"no resource row"
);
...
...
@@ -316,10 +359,10 @@ void hdddata::sellhdd(name account, uint64_t quant){
eosio_assert
(
res_itr
->
get_last_hdd_balance
()
>=
quant
,
"insufficient hdd"
);
asset
tokens_out
;
auto
itr
=
_hmarket
.
find
(
hddcore_symbol
.
raw
(
));
_hmarket
.
modify
(
itr
,
same_payer
,
[
&
](
auto
&
es
)
{
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
,
hdd_symbol
),
core_symbol
()
);
tokens_out
=
es
.
convert
(
asset
(
quant
,
S
(
0
,
HDD
)),
CORE_SYMBOL
);
});
_hbalance
.
modify
(
res_itr
,
account
,
[
&
](
auto
&
res
)
{
...
...
@@ -327,35 +370,35 @@ void hdddata::sellhdd(name account, uint64_t quant){
res
.
last_hdd_time
=
current_time
();
});
INLINE_ACTION_SENDER
(
eosio
::
token
,
transfer
)(
token_account
,
{
{
hdd_account
,
active_permission
},
{
account
,
active_permission
}
},
{
hdd_account
,
account
,
asset
(
tokens_out
),
std
::
string
(
"sell ram"
)
}
);
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
)
{
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
);
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
)
{
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
(
1
.0
/
c
.
weight
);
real_type
F
(
1000
.0
/
c
.
weight
);
real_type
E
(
in
.
amount
);
real_type
ONE
(
1.0
);
...
...
@@ -367,25 +410,25 @@ asset exchange_state::convert_from_exchange( connector& c, asset in ) {
// 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
,
const
symbol
&
to
)
{
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
(
"sell_symbol:"
,
sell_symbol
,
"
\n
"
);
print
(
"base: "
,
base_symbol
,
"
\n
"
);
print
(
"quote: "
,
quote_symbol
,
"
\n
"
);
print
(
"ex_symbol: "
,
supply
.
symbol
,
"
\n
"
);
//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
)
{
...
...
@@ -409,16 +452,21 @@ asset exchange_state::convert( asset from, const symbol& to ) {
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
,
(
init
)(
gethbalance
)(
gethsum
)(
sethfee
)(
newmaccount
)(
addmprofit
)(
subhbalance
)(
buyhdd
)(
sellhdd
)(
addhspace
)(
subhspace
)
)
EOSIO_DISPATCH_HELPER( hdddata, (gethbalance)(gethsum)(sethfee)(newmaccount)(addmprofit)(subhbalance)(buyhdd)(sellhdd)(addhspace)(subhspace) )
}
}
}
};
*/
contracts/hdddata/hdddata.hpp
浏览文件 @
1d1ac19c
...
...
@@ -6,8 +6,7 @@
using
namespace
eosio
;
using
eosio
::
name
;
using
eosio
::
asset
;
using
eosio
::
symbol
;
using
eosio
::
symbol_code
;
using
eosio
::
symbol_type
;
using
eosio
::
indexed_by
;
using
eosio
::
const_mem_fun
;
using
eosio
::
microseconds
;
...
...
@@ -20,7 +19,7 @@ typedef double real_type;
* bancor exchange is entirely contained within this struct. There are no external
* side effects associated with using this API.
*/
struct
[[
eosio
::
table
,
eosio
::
contract
(
"hdddata"
)]]
exchange_state
{
struct
exchange_state
{
asset
supply
;
struct
connector
{
...
...
@@ -33,66 +32,66 @@ struct [[eosio::table, eosio::contract("hdddata")]] exchange_state {
connector
base
;
connector
quote
;
uint64_t
primary_key
()
const
{
return
supply
.
symbol
.
raw
()
;
}
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
,
const
symbol
&
to
);
asset
convert
(
asset
from
,
symbol_type
to
);
EOSLIB_SERIALIZE
(
exchange_state
,
(
supply
)(
base
)(
quote
)
)
};
};
//comment old style declaration
typedef
multi_index
<
"hmarket"
_n
,
exchange_state
>
hmarket_table
;
typedef
multi_index
<
N
(
hmarket
)
,
exchange_state
>
hmarket_table
;
CONTRACT
hdddata
:
public
contract
{
class
hdddata
:
public
contract
{
public:
using
contract
::
contract
;
hdddata
(
name
s
,
name
code
,
datastream
<
const
char
*>
d
s
);
hdddata
(
account_name
s
);
~
hdddata
();
ACTION
init
(
name
owner
);
void
gethbalance
(
name
owner
);
ACTION
gethbalance
(
name
owner
);
void
gethsum
(
);
ACTION
gethsum
(
);
void
sethfee
(
name
owner
,
uint64_t
fee
);
ACTION
sethfee
(
name
owner
,
uint64_t
fee
);
void
newmaccount
(
name
mname
,
name
owner
);
ACTION
newmaccount
(
name
mname
,
name
owner
);
void
addmprofit
(
name
mname
,
uint64_t
space
);
ACTION
addmprofit
(
name
mname
,
uint64_t
spa
ce
);
void
subhbalance
(
name
owner
,
uint64_t
balan
ce
);
ACTION
subhbalance
(
name
owner
,
uint64_t
balance
);
void
buyhdd
(
name
buyer
,
name
receiver
,
asset
quant
);
ACTION
buyhdd
(
name
buyer
,
name
receiver
,
asse
t
quant
);
void
sellhdd
(
name
account
,
uint64_
t
quant
);
ACTION
sellhdd
(
name
account
,
uint64_t
quant
);
void
addhspace
(
name
owner
,
name
hddaccount
,
uint64_t
space
);
ACTION
add
hspace
(
name
owner
,
name
hddaccount
,
uint64_t
space
);
void
sub
hspace
(
name
owner
,
name
hddaccount
,
uint64_t
space
);
ACTION
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
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
{
"eosio.token"
_n
};
static
constexpr
eosio
::
name
hdd_account
{
"eosio.hdd"
_n
};
static
constexpr
eosio
::
name
hddfee_account
{
"eosio.hddfee"
_n
};
static
constexpr
eosio
::
name
active_permission
{
"active"
_n
};
static
symbol
get_core_symbol
(
name
system_account
=
"hddofficial"
_n
)
{
/*
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");
...
...
@@ -100,9 +99,9 @@ private:
}
symbol core_symbol() const;
TABLE
hbalance
{
name
owner
=
"hddofficial"
_n
;
*/
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
;
...
...
@@ -114,15 +113,15 @@ private:
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
<
"hbalance"
_n
,
hbalance
,
indexed_by
<
"bybalance"
_n
,
const_mem_fun
<
hbalance
,
uint64_t
,
&
hbalance
::
get_last_hdd_balance
>>
,
indexed_by
<
"byfee"
_n
,
const_mem_fun
<
hbalance
,
uint64_t
,
&
hbalance
::
get_hdd_per_cycle_fee
>>
,
indexed_by
<
"byprofit"
_n
,
const_mem_fun
<
hbalance
,
uint64_t
,
&
hbalance
::
get_hdd_per_cycle_profit
>>
,
indexed_by
<
"byspace"
_n
,
const_mem_fun
<
hbalance
,
uint64_t
,
&
hbalance
::
get_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
TABLE
maccount
{
struct
maccount
{
uint64_t
ming_id
;
name
owner
;
...
...
@@ -130,18 +129,18 @@ private:
uint64_t
get_owner
()
const
{
return
owner
.
value
;
}
};
typedef
multi_index
<
"maccount"
_n
,
maccount
,
indexed_by
<
"byowner"
_n
,
const_mem_fun
<
maccount
,
uint64_t
,
&
maccount
::
get_owner
>>>
typedef
multi_index
<
N
(
maccount
)
,
maccount
,
indexed_by
<
N
(
byowner
)
,
const_mem_fun
<
maccount
,
uint64_t
,
&
maccount
::
get_owner
>>>
maccount_table
;
TABLE
producer
{
struct
producer
{
name
owner
;
eosio
::
public_key
producer_key
;
name
producer_key
;
uint64_t
primary_key
()
const
{
return
owner
.
value
;
}
};
typedef
multi_index
<
"producer"
_n
,
producer
>
producer_table
;
typedef
multi_index
<
N
(
producer
)
,
producer
>
producer_table
;
private:
void
update_hddofficial
(
hbalance_table
&
_hblance
,
const
uint64_t
_hb
,
const
uint64_t
time
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录