Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
a4662032
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,发现更多精彩内容 >>
提交
a4662032
编写于
4月 23, 2019
作者:
B
big4david
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some issue
上级
ba628bff
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
387 addition
and
381 deletion
+387
-381
contracts/hdddata/hdddata.cpp
contracts/hdddata/hdddata.cpp
+295
-289
contracts/hdddata/hdddata.hpp
contracts/hdddata/hdddata.hpp
+92
-92
未找到文件。
contracts/hdddata/hdddata.cpp
浏览文件 @
a4662032
此差异已折叠。
点击以展开。
contracts/hdddata/hdddata.hpp
浏览文件 @
a4662032
...
...
@@ -21,46 +21,45 @@ typedef double real_type;
* side effects associated with using this API.
*/
struct
[[
eosio
::
table
,
eosio
::
contract
(
"hdddata"
)]]
exchange_state
{
asset
supply
;
asset
supply
;
struct
connector
{
asset
balance
;
double
weight
=
.5
;
struct
connector
{
asset
balance
;
double
weight
=
.5
;
EOSLIB_SERIALIZE
(
connector
,
(
balance
)(
weight
)
)
};
EOSLIB_SERIALIZE
(
connector
,
(
balance
)(
weight
)
)
};
connector
base
;
connector
quote
;
connector
base
;
connector
quote
;
uint64_t
primary_key
()
const
{
return
supply
.
symbol
.
raw
();
}
uint64_t
primary_key
()
const
{
return
supply
.
symbol
.
raw
();
}
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_to_exchange
(
connector
&
c
,
asset
in
);
asset
convert_from_exchange
(
connector
&
c
,
asset
in
);
asset
convert
(
asset
from
,
const
symbol
&
to
);
EOSLIB_SERIALIZE
(
exchange_state
,
(
supply
)(
base
)(
quote
)
)
EOSLIB_SERIALIZE
(
exchange_state
,
(
supply
)(
base
)(
quote
)
)
};
//comment old style declaration
typedef
multi_index
<
"hmarket"
_n
,
exchange_state
>
hmarket_table
;
CONTRACT
hdddata
:
public
contract
{
public:
using
contract
::
contract
;
hdddata
(
name
s
,
name
code
,
datastream
<
const
char
*>
ds
);
CONTRACT
hdddata
:
public
contract
{
public:
using
contract
::
contract
;
hdddata
(
name
s
,
name
code
,
datastream
<
const
char
*>
ds
);
~
hdddata
();
ACTION
init
(
name
owner
);
ACTION
gethbalance
(
name
owner
);
ACTION
gethsum
();
ACTION
init
(
name
owner
);
ACTION
gethbalance
(
name
owner
);
ACTION
gethsum
();
ACTION
sethfee
(
name
owner
,
uint64_t
fee
);
ACTION
newmaccount
(
name
mname
,
name
owner
);
...
...
@@ -70,83 +69,84 @@ CONTRACT hdddata : public contract
ACTION
subhbalance
(
name
owner
,
uint64_t
balance
);
ACTION
buyhdd
(
name
buyer
,
name
receiver
,
asset
quant
);
ACTION
sellhdd
(
name
account
,
uint64_t
quant
);
ACTION
addhspace
(
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
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
)
{
hmarket_table
rm
(
system_account
,
system_account
.
value
);
const
static
auto
sym
=
get_core_symbol
(
rm
);
return
sym
;
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
)
{
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
;
TABLE
hbalance
{
name
owner
=
"hddofficial"
_n
;
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
();
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
;
}
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
;
TABLE
hbalance
{
name
owner
=
"hddofficial"
_n
;
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
();
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
<
"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
>>>
hbalance_table
;
// ming account
TABLE
maccount
{
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
>>>
hbalance_table
;
// ming account
TABLE
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
<
"maccount"
_n
,
maccount
,
indexed_by
<
"byowner"
_n
,
const_mem_fun
<
maccount
,
uint64_t
,
&
maccount
::
get_owner
>>>
maccount_table
;
TABLE
producer
{
name
owner
;
eosio
::
public_key
producer_key
;
uint64_t
primary_key
()
const
{
return
owner
.
value
;
}
};
indexed_by
<
"byowner"
_n
,
const_mem_fun
<
maccount
,
uint64_t
,
&
maccount
::
get_owner
>>>
maccount_table
;
TABLE
producer
{
name
owner
;
eosio
::
public_key
producer_key
;
uint64_t
primary_key
()
const
{
return
owner
.
value
;
}
};
typedef
multi_index
<
"producer"
_n
,
producer
>
producer_table
;
private:
//hbalance_table _hbalance;
maccount_table
_maccount
;
producer_table
_producer
;
private:
//hbalance_table _hbalance;
maccount_table
_maccount
;
producer_table
_producer
;
hmarket_table
_hmarket
;
};
\ No newline at end of file
};
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录