Commit 1239ea28 authored by madengji's avatar madengji Committed by 33cn

para bind miner

parent d1046df7
......@@ -85,8 +85,14 @@ maxTxNumber = 1600
[mver.consensus.paracross]
#超级节点挖矿奖励
coinReward=18
#发展基金奖励
coinDevFund=12
#如果超级节点上绑定了委托账户,则奖励超级节点coinBaseReward,其余部分(coinReward-coinBaseReward)按权重分给委托账户
coinBaseReward=5
#委托账户最少解绑定时间(按小时)
unBindTime=24
[consensus.sub.para]
......
......@@ -300,6 +300,15 @@ func (a *action) getNodesGroup(title string) (map[string]struct{}, []string, err
}
func (a *action) isValidSuperNode(addr string) (bool, error) {
cfg := a.api.GetConfig()
nodes, _, err := getParacrossNodes(a.db, cfg.GetTitle())
if err != nil {
return false, errors.Wrapf(err, "getNodes for title:%s", cfg.GetTitle())
}
return validNode(addr, nodes), nil
}
//相同的BlockHash,只保留一份数据
func updateCommitBlockHashs(stat *pt.ParacrossHeightStatus, commit *pt.ParacrossNodeStatus) {
if stat.BlockDetails == nil {
......
......@@ -119,3 +119,9 @@ func (e *Paracross) Exec_SelfStageConfig(payload *pt.ParaStageConfig, tx *types.
a := newAction(e, tx)
return a.SelfStageConfig(payload)
}
//Exec_ParaBindMiner node group config process
func (e *Paracross) Exec_ParaBindMiner(payload *pt.ParaBindMinerInfo, tx *types.Transaction, index int) (*types.Receipt, error) {
a := newAction(e, tx)
return a.bindMiner(payload)
}
......@@ -35,6 +35,9 @@ var (
paraSelfConsensStages string
paraSelfConsensStageIDPrefix string
paraBindMinderAddr string
paraBindMinderNode string
)
func setPrefix() {
......@@ -50,6 +53,10 @@ func setPrefix() {
paraSelfConsensStages = "mavl-paracross-selfconsens-stages-"
paraSelfConsensStageIDPrefix = "mavl-paracross-selfconsens-id-"
//bind miner
paraBindMinderAddr = "mavl-paracross-bindmineraddr-"
paraBindMinderNode = "mavl-paracross-bindminernode-"
localTx = "LODB-paracross-titleHeightAddr-"
localTitle = "LODB-paracross-title-"
localTitleHeight = "LODB-paracross-titleHeight-"
......@@ -179,3 +186,16 @@ func calcLocalNodeGroupStatusPrefix(status int32) []byte {
func calcLocalNodeGroupAllPrefix() []byte {
return []byte(fmt.Sprintf(localNodeGroupStatusTitle))
}
//bind miner
func calcParaBindMinerAddr(node, bind string) []byte {
return []byte(fmt.Sprintf(paraBindMinderAddr+"%s-%s", node, bind))
}
func calcParaBindMinerNode(node string) []byte {
return []byte(paraBindMinderNode + node)
}
func calcParaBindMinerNodePrefix() []byte {
return []byte(paraBindMinderNode)
}
This diff is collapsed.
......@@ -158,6 +158,31 @@ message RespParacrossNodeGroups {
repeated ParaNodeGroupStatus ids = 1;
}
//para bind miner
message ParaBindMinerInfo{
string addr = 1; // miner addr
int32 bindStatus = 2; // 0: init, 1: bind, 2:unbind
int64 bindCount = 3; // bind coins count
int64 blockTime = 4; // status bind block time
string targetAddr = 5; // super node addr
}
message ReceiptParaBindMinerInfo{
string addr = 1; // miner addr
ParaBindMinerInfo prev = 2;
ParaBindMinerInfo current = 3;
}
message ParaNodeBindList{
string superNode = 1;
repeated string miners = 2;
}
message ReceiptParaNodeBindListUpdate{
ParaNodeBindList prev = 1;
ParaNodeBindList current = 2;
}
message ParaBlock2MainMap {
int64 height = 1;
string blockHash = 2;
......
......@@ -47,6 +47,8 @@ const (
TyLogParaStageGroupUpdate = 667
//TyLogParaCrossAssetTransfer 统一的跨链资产转移
TyLogParaCrossAssetTransfer = 670
TyLogParaBindMinerAddr = 671
TyLogParaBindMinerNode = 672
)
// action type
......@@ -61,6 +63,8 @@ const (
ParacrossActionWithdraw
// ParacrossActionTransferToExec asset transfer to exec
ParacrossActionTransferToExec
// ParacrossActionParaBindMiner para chain bind super node miner
ParacrossActionParaBindMiner
)
const (
......
......@@ -109,6 +109,8 @@ func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo {
TyLogParaSelfConsStageConfig: {Ty: reflect.TypeOf(ReceiptSelfConsStageConfig{}), Name: "LogParaSelfConsStageConfig"},
TyLogParaStageVoteDone: {Ty: reflect.TypeOf(ReceiptSelfConsStageVoteDone{}), Name: "LogParaSelfConfStageVoteDoen"},
TyLogParaStageGroupUpdate: {Ty: reflect.TypeOf(ReceiptSelfConsStagesUpdate{}), Name: "LogParaSelfConfStagesUpdate"},
TyLogParaBindMinerAddr: {Ty: reflect.TypeOf(ReceiptParaBindMinerInfo{}), Name: "TyLogParaBindMinerAddrUpdate"},
TyLogParaBindMinerNode: {Ty: reflect.TypeOf(ReceiptParaNodeBindListUpdate{}), Name: "TyLogParaBindNodeListUpdate"},
}
}
......@@ -126,6 +128,7 @@ func (p *ParacrossType) GetTypeMap() map[string]int32 {
"NodeConfig": ParacrossActionNodeConfig,
"NodeGroupConfig": ParacrossActionNodeGroupApply,
"SelfStageConfig": ParacrossActionSelfStageConfig,
"ParaBindMiner": ParacrossActionParaBindMiner,
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment