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

add super manager to vote

parent a65469f6
......@@ -9,11 +9,16 @@ import (
"encoding/gob"
dbm "github.com/33cn/chain33/common/db"
manager "github.com/33cn/chain33/system/dapp/manage/types"
"github.com/33cn/chain33/types"
pt "github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/pkg/errors"
)
var (
conf = types.ConfSub(manager.ManageX)
)
func deepCopy(dst, src interface{}) error {
var buf bytes.Buffer
if err := gob.NewEncoder(&buf).Encode(src); err != nil {
......@@ -179,6 +184,16 @@ func (a *action) nodeDelete(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
}
// IsSuperManager is supper manager or not
func isSuperManager(addr string) bool {
for _, m := range conf.GStrList("superManager") {
if addr == m {
return true
}
}
return false
}
func getMostVote(stat *pt.ParaNodeAddrStatus) (int, string) {
var ok, nok int
for _, v := range stat.GetVotes().Votes {
......@@ -205,7 +220,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
if err != nil {
return nil, errors.Wrapf(err, "getNodes for title:%s", config.Title)
}
if !validNode(a.fromaddr, nodes) {
if !validNode(a.fromaddr, nodes) && !isSuperManager(a.fromaddr) {
return nil, errors.Wrapf(pt.ErrNodeNotForTheTitle, "not validNode:%s", a.fromaddr)
}
......@@ -250,8 +265,11 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
receipt := makeNodeConfigReceipt(a.fromaddr, config, &copyStat, stat)
most, vote := getMostVote(stat)
if !isCommitDone(stat, nodes, most) {
saveNodeAddr(a.db, key, stat)
return receipt, nil
//超级用户且当前group里面有任一账户投yes票,可以通过
if !(isSuperManager(a.fromaddr) && most > 1 && vote == pt.ParaNodeVoteYes) {
saveNodeAddr(a.db, key, stat)
return receipt, nil
}
}
clog.Info("paracross.nodeVote ----pass", "most", most, "pass", vote)
......
......@@ -8,6 +8,7 @@
1. 平行链接管初始授权账户后,初始授权账户审核后续新授权账户的添加和退出申请工作,必须除自己外,超过2/3数同意
才可加入和退出,如果只剩最后一个账户,则不允许退出,如果随意退出有只留下僵尸授权账户风险,平行链失控
1. 当前授权账户有投票删除某一个授权账户的权利,2/3数同意的规则
1. 新申请账户在当前任一账户同意条件下,超级账户投票有直接通过权利,尤其是在当前授权账户不足2/3达不成共识时候,需要超级账户干预
1. 特殊或异常场景:
1. 新申请节点还没投票就退出,不允许,必须都投完票之后再申请
1. 申请节点退出后重新申请,允许重新加入,但需要重新投票
......@@ -31,4 +32,5 @@
1. 已加入节点申请退出,超2/3同意,已加入节点退出管理组处于quited状态
1. 新节点重新申请加入,超2/3否决,新节点仍停留在adding状态,后来投票节点又2/3同意,新节点加入
1. 投票节点一起投某一个账户组里面的账户否决票,超2/3数后,此账户退出账户组,又超过2/3同意后,仍处于退出状态(需自己申请加入)
1. 账户组里面账户申请退出,当是最后一个时候退出失败
\ No newline at end of file
1. 账户组里面账户申请退出,当是最后一个时候退出失败
1. 配4个节点,只有2个可以投票发共识消息,共识停止,2个新节点申请加入,其中一节点vote通过后,超级账户vote后通过,加入管理组参与共识
\ No newline at end of file
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