Commit aa8a0c88 authored by mdj33's avatar mdj33 Committed by vipwzw

added addr cancel operation

parent cfa64635
...@@ -251,12 +251,12 @@ func CreateRawNodeManageCmd() *cobra.Command { ...@@ -251,12 +251,12 @@ func CreateRawNodeManageCmd() *cobra.Command {
} }
func addNodeManageFlags(cmd *cobra.Command) { func addNodeManageFlags(cmd *cobra.Command) {
cmd.Flags().Uint32P("operation", "o", 0, "operation:1:join,2:vote,3:quit") cmd.Flags().Uint32P("operation", "o", 0, "operation:1:join,2:vote,3:quit,4:cancel")
cmd.MarkFlagRequired("operation") cmd.MarkFlagRequired("operation")
cmd.Flags().StringP("addr", "a", "", "operating target addr") cmd.Flags().StringP("addr", "a", "", "operating target addr[optional]")
cmd.Flags().StringP("id", "i", "", "operating target id") cmd.Flags().StringP("id", "i", "", "operating target id[optional]")
cmd.Flags().Uint32P("value", "v", 1, "vote value: 1:yes,2:no") cmd.Flags().Uint32P("value", "v", 1, "vote value: 1:yes,2:no")
cmd.Flags().Float64P("coins_frozen", "c", 0, "frozen coins amount, should not less nodegroup's") cmd.Flags().Float64P("coins_frozen", "c", 0, "frozen coins amount, should not less nodegroup's")
......
...@@ -261,10 +261,10 @@ func (a *action) getNodesGroup(title string) (map[string]struct{}, error) { ...@@ -261,10 +261,10 @@ func (a *action) getNodesGroup(title string) (map[string]struct{}, error) {
} }
//根据nodes过滤掉可能退出了的addrs //根据nodes过滤掉可能退出了的addrs
func updateCommitAddrs(stat *pt.ParacrossHeightStatus,nodes map[string]struct{}){ func updateCommitAddrs(stat *pt.ParacrossHeightStatus, nodes map[string]struct{}) {
details := &pt.ParacrossStatusDetails{} details := &pt.ParacrossStatusDetails{}
for i,addr := range stat.Details.Addrs{ for i, addr := range stat.Details.Addrs {
if _,ok :=nodes[addr]; ok{ if _, ok := nodes[addr]; ok {
details.Addrs = append(details.Addrs, addr) details.Addrs = append(details.Addrs, addr)
details.BlockHash = append(details.BlockHash, stat.Details.BlockHash[i]) details.BlockHash = append(details.BlockHash, stat.Details.BlockHash[i])
} }
...@@ -378,8 +378,8 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error ...@@ -378,8 +378,8 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
receipt = makeCommitReceipt(a.fromaddr, commit, &copyStat, stat) receipt = makeCommitReceipt(a.fromaddr, commit, &copyStat, stat)
} }
if types.IsDappFork(commit.Status.MainBlockHeight, pt.ParaX, pt.ForkCommitTx){ if types.IsDappFork(commit.Status.MainBlockHeight, pt.ParaX, pt.ForkCommitTx) {
updateCommitAddrs(stat,nodes) updateCommitAddrs(stat, nodes)
} }
clog.Info("paracross.Commit commit", "stat.title", stat.Title, "stat.height", stat.Height, "notes", len(nodes)) clog.Info("paracross.Commit commit", "stat.title", stat.Title, "stat.height", stat.Height, "notes", len(nodes))
......
...@@ -353,17 +353,17 @@ func TestGetAddrGroup(t *testing.T) { ...@@ -353,17 +353,17 @@ func TestGetAddrGroup(t *testing.T) {
} }
func TestUpdateVotes(t *testing.T){ func TestUpdateVotes(t *testing.T) {
stat := &pt.ParaNodeIdStatus{} stat := &pt.ParaNodeIdStatus{}
votes := &pt.ParaNodeVoteDetail{ votes := &pt.ParaNodeVoteDetail{
Addrs:[]string{"AA","BB","CC"}, Addrs: []string{"AA", "BB", "CC"},
Votes:[]string{"yes","no","no"}} Votes: []string{"yes", "no", "no"}}
stat.Votes = votes stat.Votes = votes
nodes := make(map[string]struct{}) nodes := make(map[string]struct{})
nodes["BB"]= struct{}{} nodes["BB"] = struct{}{}
nodes["CC"] = struct{}{} nodes["CC"] = struct{}{}
updateVotes(stat,nodes) updateVotes(stat, nodes)
assert.Equal(t,[]string{"BB","CC"},stat.Votes.Addrs) assert.Equal(t, []string{"BB", "CC"}, stat.Votes.Addrs)
assert.Equal(t,[]string{"no","no"},stat.Votes.Votes) assert.Equal(t, []string{"no", "no"}, stat.Votes.Votes)
} }
\ No newline at end of file
...@@ -63,7 +63,11 @@ message ParaNodeVoteDetail { ...@@ -63,7 +63,11 @@ message ParaNodeVoteDetail {
} }
message ParaNodeAddrIdStatus { message ParaNodeAddrIdStatus {
string proposalId = 1; string addr = 1;
string proposalId = 2;
string quitId = 3;
int32 status = 4;
string title = 5;
} }
message ParaNodeIdStatus { message ParaNodeIdStatus {
...@@ -85,6 +89,11 @@ message ReceiptParaNodeConfig { ...@@ -85,6 +89,11 @@ message ReceiptParaNodeConfig {
ParaNodeIdStatus current = 4; ParaNodeIdStatus current = 4;
} }
message ReceiptParaNodeAddrStatUpdate {
string fromAddr = 1;
ParaNodeAddrIdStatus prev = 2;
ParaNodeAddrIdStatus current = 3;
}
message ReceiptParaNodeVoteDone { message ReceiptParaNodeVoteDone {
string id = 1; string id = 1;
......
...@@ -45,8 +45,8 @@ var ( ...@@ -45,8 +45,8 @@ var (
ErrParaNodeVoteSelf = errors.New("ErrParaNodeVoteSelf") ErrParaNodeVoteSelf = errors.New("ErrParaNodeVoteSelf")
//ErrParaNodeGroupFrozenCoinsNotEnough node group coins in tx less than conf's minimum coins //ErrParaNodeGroupFrozenCoinsNotEnough node group coins in tx less than conf's minimum coins
ErrParaNodeGroupFrozenCoinsNotEnough = errors.New("ErrParaNodeGroupFrozenCoinsNotEnough") ErrParaNodeGroupFrozenCoinsNotEnough = errors.New("ErrParaNodeGroupFrozenCoinsNotEnough")
//ErrParaNodeGroupStatusWrong node group process wrong status //ErrParaNodeOpStatusWrong node process wrong status
ErrParaNodeGroupStatusWrong = errors.New("ErrParaNodeGroupStatusWrong") ErrParaNodeOpStatusWrong = errors.New("ErrParaNodeOpStatusWrong")
//ErrParaConsensStopBlocksNotReach consensus stop blocks not reach //ErrParaConsensStopBlocksNotReach consensus stop blocks not reach
ErrParaConsensStopBlocksNotReach = errors.New("ErrParaConsensStopBlocksNotReach") ErrParaConsensStopBlocksNotReach = errors.New("ErrParaConsensStopBlocksNotReach")
) )
...@@ -41,6 +41,7 @@ const ( ...@@ -41,6 +41,7 @@ const (
TyLogParaNodeVoteDone = 658 TyLogParaNodeVoteDone = 658
TyLogParaNodeGroupAddrsUpdate = 659 TyLogParaNodeGroupAddrsUpdate = 659
TyLogParaNodeGroupConfig = 660 TyLogParaNodeGroupConfig = 660
TyLogParaNodeStatusUpdate = 661
TyLogParaNodeGroupStatusUpdate = 664 TyLogParaNodeGroupStatusUpdate = 664
) )
...@@ -92,6 +93,7 @@ const ( ...@@ -92,6 +93,7 @@ const (
ParaNodeJoin = iota + 1 ParaNodeJoin = iota + 1
ParaNodeVote ParaNodeVote
ParaNodeQuit ParaNodeQuit
ParaNodeCancel
) )
// node vote op // node vote op
...@@ -114,6 +116,8 @@ const ( ...@@ -114,6 +116,8 @@ const (
ParacrossNodeQuiting ParacrossNodeQuiting
// ParacrossNodeQuited pass to quite by votes // ParacrossNodeQuited pass to quite by votes
ParacrossNodeQuited ParacrossNodeQuited
// ParacrossNodeCanceled to cancel apply of joining or quiting
ParacrossNodeCanceled
) )
const ( const (
......
...@@ -62,6 +62,7 @@ func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo { ...@@ -62,6 +62,7 @@ func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo {
TyLogParaAssetDeposit: {Ty: reflect.TypeOf(types.ReceiptAccountTransfer{}), Name: "LogParaAssetDeposit"}, TyLogParaAssetDeposit: {Ty: reflect.TypeOf(types.ReceiptAccountTransfer{}), Name: "LogParaAssetDeposit"},
TyLogParacrossMiner: {Ty: reflect.TypeOf(ReceiptParacrossMiner{}), Name: "LogParacrossMiner"}, TyLogParacrossMiner: {Ty: reflect.TypeOf(ReceiptParacrossMiner{}), Name: "LogParacrossMiner"},
TyLogParaNodeConfig: {Ty: reflect.TypeOf(ReceiptParaNodeConfig{}), Name: "LogParaNodeConfig"}, TyLogParaNodeConfig: {Ty: reflect.TypeOf(ReceiptParaNodeConfig{}), Name: "LogParaNodeConfig"},
TyLogParaNodeStatusUpdate: {Ty: reflect.TypeOf(ReceiptParaNodeAddrStatUpdate{}), Name: "LogParaNodeAddrStatUpdate"},
TyLogParaNodeGroupAddrsUpdate: {Ty: reflect.TypeOf(types.ReceiptConfig{}), Name: "LogParaNodeGroupAddrsUpdate"}, TyLogParaNodeGroupAddrsUpdate: {Ty: reflect.TypeOf(types.ReceiptConfig{}), Name: "LogParaNodeGroupAddrsUpdate"},
TyLogParaNodeVoteDone: {Ty: reflect.TypeOf(ReceiptParaNodeVoteDone{}), Name: "LogParaNodeVoteDone"}, TyLogParaNodeVoteDone: {Ty: reflect.TypeOf(ReceiptParaNodeVoteDone{}), Name: "LogParaNodeVoteDone"},
TyLogParaNodeGroupConfig: {Ty: reflect.TypeOf(ReceiptParaNodeGroupConfig{}), Name: "LogParaNodeGroupConfig"}, TyLogParaNodeGroupConfig: {Ty: reflect.TypeOf(ReceiptParaNodeGroupConfig{}), Name: "LogParaNodeGroupConfig"},
......
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