Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
016636ae
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,发现更多精彩内容 >>
提交
016636ae
编写于
6月 05, 2019
作者:
W
Wang Zhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hddpool contract: code formatting
上级
098ae99f
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
397 addition
and
364 deletion
+397
-364
contracts/hddpool/hddpool.cpp
contracts/hddpool/hddpool.cpp
+276
-246
contracts/hddpool/hddpool.hpp
contracts/hddpool/hddpool.hpp
+121
-118
未找到文件。
contracts/hddpool/hddpool.cpp
浏览文件 @
016636ae
此差异已折叠。
点击以展开。
contracts/hddpool/hddpool.hpp
浏览文件 @
016636ae
...
@@ -3,142 +3,145 @@
...
@@ -3,142 +3,145 @@
#include <eosiolib/time.hpp>
#include <eosiolib/time.hpp>
#include <eosiolib/singleton.hpp>
#include <eosiolib/singleton.hpp>
using
eosio
::
contract
;
using
eosio
::
name
;
using
eosio
::
asset
;
using
eosio
::
asset
;
using
eosio
::
symbol_type
;
using
eosio
::
indexed_by
;
using
eosio
::
const_mem_fun
;
using
eosio
::
const_mem_fun
;
using
eosio
::
microseconds
;
using
eosio
::
contract
;
using
eosio
::
datastream
;
using
eosio
::
datastream
;
using
eosio
::
indexed_by
;
using
eosio
::
microseconds
;
using
eosio
::
multi_index
;
using
eosio
::
multi_index
;
using
eosio
::
name
;
using
eosio
::
symbol_type
;
typedef
double
real_type
;
typedef
double
real_type
;
//copy from eosio.system
//copy from eosio.system
/**
/**
* Uses Bancor math to create a 50/50 relay between two asset types. The state of the
* 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
* bancor exchange is entirely contained within this struct. There are no external
* side effects associated with using this API.
* side effects associated with using this API.
*/
*/
struct
exchange_state
{
struct
exchange_state
asset
supply
;
{
asset
supply
;
struct
connector
{
struct
connector
asset
balance
;
{
double
weight
=
.5
;
asset
balance
;
double
weight
=
.5
;
EOSLIB_SERIALIZE
(
connector
,
(
balance
)(
weight
)
)
EOSLIB_SERIALIZE
(
connector
,
(
balance
)(
weight
)
)
};
};
connector
base
;
connector
base
;
connector
quote
;
connector
quote
;
uint64_t
primary_key
()
const
{
return
supply
.
symbol
;
}
uint64_t
primary_key
()
const
{
return
supply
.
symbol
;
}
asset
convert_to_exchange
(
connector
&
c
,
asset
in
);
asset
convert_to_exchange
(
connector
&
c
,
asset
in
);
asset
convert_from_exchange
(
connector
&
c
,
asset
in
);
asset
convert_from_exchange
(
connector
&
c
,
asset
in
);
asset
convert
(
asset
from
,
symbol_type
to
);
asset
convert
(
asset
from
,
symbol_type
to
);
EOSLIB_SERIALIZE
(
exchange_state
,
(
supply
)(
base
)(
quote
)
)
EOSLIB_SERIALIZE
(
exchange_state
,
(
supply
)(
base
)(
quote
)
)
};
};
//comment old style declaration
//comment old style declaration
typedef
multi_index
<
N
(
hmarket
),
exchange_state
>
hmarket_table
;
typedef
multi_index
<
N
(
hmarket
),
exchange_state
>
hmarket_table
;
class
hddpool
:
public
contract
{
class
hddpool
:
public
contract
{
public:
public:
using
contract
::
contract
;
using
contract
::
contract
;
hddpool
(
account_name
s
);
hddpool
(
account_name
s
);
~
hddpool
();
~
hddpool
();
void
getbalance
(
name
user
);
void
getbalance
(
name
user
);
void
buyhdd
(
name
user
,
asset
quant
);
void
buyhdd
(
name
user
,
asset
quant
);
//void buyhdd( name user , int64_t amount);
//void buyhdd( name user , int64_t amount);
void
sellhdd
(
name
user
,
int64_t
amount
);
void
sellhdd
(
name
user
,
int64_t
amount
);
void
sethfee
(
name
user
,
int64_t
fee
);
void
sethfee
(
name
user
,
int64_t
fee
);
void
subbalance
(
name
user
,
int64_t
balance
);
void
subbalance
(
name
user
,
int64_t
balance
);
void
addhspace
(
name
user
,
uint64_t
space
);
void
addhspace
(
name
user
,
uint64_t
space
);
void
subhspace
(
name
user
,
uint64_t
space
);
void
subhspace
(
name
user
,
uint64_t
space
);
void
newmaccount
(
name
owner
,
uint64_t
minerid
);
void
newmaccount
(
name
owner
,
uint64_t
minerid
);
void
addmprofit
(
name
owner
,
uint64_t
minerid
,
uint64_t
space
);
void
addmprofit
(
name
owner
,
uint64_t
minerid
,
uint64_t
space
);
void
clearall
();
void
clearall
();
void
calcmbalance
(
name
owner
,
uint64_t
minerid
);
void
calcmbalance
(
name
owner
,
uint64_t
minerid
);
private:
private:
struct
userhdd
{
struct
userhdd
{
name
account_name
;
//账户名
name
account_name
;
//账户名
int64_t
hdd_balance
;
//余额
int64_t
hdd_balance
;
//余额
int64_t
hdd_per_cycle_fee
;
//每周期费用
int64_t
hdd_per_cycle_fee
;
//每周期费用
int64_t
hdd_per_cycle_profit
;
//每周期收益
int64_t
hdd_per_cycle_profit
;
//每周期收益
uint64_t
hdd_space
;
//占用存储空间
uint64_t
hdd_space
;
//占用存储空间
uint64_t
last_hdd_time
;
//上次余额计算时间 microseconds from 1970
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
;
typedef
multi_index
<
N
(
userhdd
),
userhdd
>
userhdd_index
;
struct
maccount
struct
maccount
{
{
uint64_t
minerid
;
//矿机id
uint64_t
minerid
;
//矿机id
name
owner
;
//拥有矿机的矿主的账户名
name
owner
;
//拥有矿机的矿主的账户名
uint64_t
space
;
//生产空间
uint64_t
space
;
//生产空间
int64_t
hdd_per_cycle_profit
;
//每周期收益
int64_t
hdd_per_cycle_profit
;
//每周期收益
int64_t
hdd_balance
;
//余额
int64_t
hdd_balance
;
//余额
uint64_t
last_hdd_time
;
//上次余额计算时间 microseconds from 1970
uint64_t
last_hdd_time
;
//上次余额计算时间 microseconds from 1970
uint64_t
primary_key
()
const
{
return
minerid
;
}
uint64_t
primary_key
()
const
{
return
minerid
;
}
//uint64_t get_owner() const { return owner.value; }
//uint64_t get_owner() const { return owner.value; }
};
};
typedef
multi_index
<
N
(
maccount
),
maccount
>
maccount_index
;
typedef
multi_index
<
N
(
maccount
),
maccount
>
maccount_index
;
struct
hdd_global_state
struct
hdd_global_state
{
{
int64_t
hdd_total_balance
=
10000000000
;
int64_t
hdd_total_balance
=
10000000000
;
};
};
struct
hdd_global_state2
{
struct
hdd_global_state2
uint64_t
hdd_total_user
=
4
;
{
};
uint64_t
hdd_total_user
=
4
;
};
struct
hdd_global_state3
{
uint64_t
hdd_macc_user
=
2
;
struct
hdd_global_state3
};
{
uint64_t
hdd_macc_user
=
2
;
struct
hdd_global_price
{
};
int64_t
price
=
70
;
};
struct
hdd_global_price
{
int64_t
price
=
70
;
typedef
eosio
::
singleton
<
N
(
hddglobal
),
hdd_global_state
>
global_state_singleton
;
};
typedef
eosio
::
singleton
<
N
(
gusercount
),
hdd_global_state2
>
gusercount_singleton
;
typedef
eosio
::
singleton
<
N
(
gmacccount
),
hdd_global_state3
>
gmacccount_singleton
;
typedef
eosio
::
singleton
<
N
(
hddglobal
),
hdd_global_state
>
global_state_singleton
;
typedef
eosio
::
singleton
<
N
(
ghddprice
),
hdd_global_price
>
ghddprice_singleton
;
typedef
eosio
::
singleton
<
N
(
gusercount
),
hdd_global_state2
>
gusercount_singleton
;
typedef
eosio
::
singleton
<
N
(
gmacccount
),
hdd_global_state3
>
gmacccount_singleton
;
global_state_singleton
_global
;
typedef
eosio
::
singleton
<
N
(
ghddprice
),
hdd_global_price
>
ghddprice_singleton
;
hdd_global_state
_gstate
;
global_state_singleton
_global
;
gusercount_singleton
_global2
;
hdd_global_state
_gstate
;
hdd_global_state2
_gstate2
;
gusercount_singleton
_global2
;
gmacccount_singleton
_global3
;
hdd_global_state2
_gstate2
;
hdd_global_state3
_gstate3
;
gmacccount_singleton
_global3
;
ghddprice_singleton
_ghddprice
;
hdd_global_state3
_gstate3
;
hdd_global_price
_ghddpriceState
;
ghddprice_singleton
_ghddprice
;
hmarket_table
_hmarket
;
hdd_global_price
_ghddpriceState
;
hmarket_table
_hmarket
;
bool
is_bp_account
(
uint64_t
uservalue
);
bool
is_bp_account
(
uint64_t
uservalue
);
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
,
bool
calculate_balance
(
int64_t
oldbalance
,
int64_t
hdd_per_cycle_fee
,
int64_t
&
new_balance
);
int64_t
hdd_per_cycle_profit
,
uint64_t
last_hdd_time
,
uint64_t
current_time
,
int64_t
&
new_balance
);
void
update_hddofficial
(
const
int64_t
_balance
,
const
int64_t
_fee
,
const
int64_t
_profit
,
void
update_hddofficial
(
const
int64_t
_balance
,
const
int64_t
_space
);
const
int64_t
_fee
,
const
int64_t
_profit
,
const
int64_t
_space
);
void
update_total_hdd_balance
(
int64_t
_balance_delta
);
void
update_total_hdd_balance
(
int64_t
_balance_delta
);
};
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录