Commit 72e879e6 authored by liuyuhang's avatar liuyuhang Committed by 33cn

merge func

parent 158281da
...@@ -57,21 +57,11 @@ func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) { ...@@ -57,21 +57,11 @@ func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) {
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
} }
// 获取当前生效提案规则,并且将不修改的规则补齐 // 获取当前生效提案规则
rule := &auty.RuleConfig{} rule, err := a.getActiveRule()
value, err := a.db.Get(activeRuleID()) if err != nil {
if err == nil { alog.Error("propBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "getActiveRule failed", err)
err = types.Decode(value, rule) return nil, err
if err != nil {
alog.Error("propBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode ProposalRule failed", err)
return nil, err
}
} else {// 载入系统默认值
rule.BoardAttendRatio = boardAttendRatio
rule.BoardApproveRatio = boardApproveRatio
rule.PubOpposeRatio = pubOpposeRatio
rule.ProposalAmount = proposalAmount
rule.LargeProjectAmount = largeProjectAmount
} }
receipt, err := a.coinsAccount.ExecFrozen(a.fromaddr, a.execaddr, rule.ProposalAmount) receipt, err := a.coinsAccount.ExecFrozen(a.fromaddr, a.execaddr, rule.ProposalAmount)
...@@ -105,21 +95,13 @@ func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) { ...@@ -105,21 +95,13 @@ func (a *action) propBoard(prob *auty.ProposalBoard) (*types.Receipt, error) {
} }
func (a *action) rvkPropBoard(rvkProb *auty.RevokeProposalBoard) (*types.Receipt, error) { func (a *action) rvkPropBoard(rvkProb *auty.RevokeProposalBoard) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalBoard(rvkProb.ProposalID)
value, err := a.db.Get(propBoardID(rvkProb.ProposalID))
if err != nil { if err != nil {
alog.Error("rvkPropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "get ProposalBoard) failed", alog.Error("rvkPropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalBoard failed",
rvkProb.ProposalID, "err", err) rvkProb.ProposalID, "err", err)
return nil, err return nil, err
} }
var cur auty.AutonomyProposalBoard pre := copyAutonomyProposalBoard(cur)
err = types.Decode(value, &cur)
if err != nil {
alog.Error("rvkPropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode ProposalBoard failed",
rvkProb.ProposalID, "err", err)
return nil, err
}
pre := copyAutonomyProposalBoard(&cur)
// 检查当前状态 // 检查当前状态
if cur.Status != auty.AutonomyStatusProposalBoard { if cur.Status != auty.AutonomyStatusProposalBoard {
...@@ -157,29 +139,21 @@ func (a *action) rvkPropBoard(rvkProb *auty.RevokeProposalBoard) (*types.Receipt ...@@ -157,29 +139,21 @@ func (a *action) rvkPropBoard(rvkProb *auty.RevokeProposalBoard) (*types.Receipt
cur.Status = auty.AutonomyStatusRvkPropBoard cur.Status = auty.AutonomyStatusRvkPropBoard
kv = append(kv, &types.KeyValue{Key: propBoardID(rvkProb.ProposalID), Value: types.Encode(&cur)}) kv = append(kv, &types.KeyValue{Key: propBoardID(rvkProb.ProposalID), Value: types.Encode(cur)})
getReceiptLog(pre, &cur, auty.TyLogRvkPropBoard) getReceiptLog(pre, cur, auty.TyLogRvkPropBoard)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt, error) { func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalBoard(voteProb.ProposalID)
value, err := a.db.Get(propBoardID(voteProb.ProposalID))
if err != nil { if err != nil {
alog.Error("votePropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "get propBoardID failed", alog.Error("votePropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalBoard failed",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
var cur auty.AutonomyProposalBoard pre := copyAutonomyProposalBoard(cur)
err = types.Decode(value, &cur)
if err != nil {
alog.Error("votePropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode AutonomyProposalBoard failed",
voteProb.ProposalID, "err", err)
return nil, err
}
pre := copyAutonomyProposalBoard(&cur)
// 检查当前状态 // 检查当前状态
if cur.Status != auty.AutonomyStatusProposalBoard && cur.Status != auty.AutonomyStatusVotePropBoard { if cur.Status != auty.AutonomyStatusProposalBoard && cur.Status != auty.AutonomyStatusVotePropBoard {
...@@ -200,27 +174,13 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt ...@@ -200,27 +174,13 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
} }
// 检查是否已经参与投票 // 检查是否已经参与投票
var votes auty.VotesRecord votes, err := a.checkVotesRecord(voteProb.ProposalID)
value, err = a.db.Get(VotesRecord(voteProb.ProposalID)) if err != nil {
if err == nil { alog.Error("votePropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "checkVotesRecord failed",
err = types.Decode(value, &votes) voteProb.ProposalID, "err", err)
if err != nil { return nil, err
alog.Error("votePropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode VotesRecord failed",
voteProb.ProposalID, "err", err)
return nil, err
}
}
// 检查是否有重复
for _, addr := range votes.Address {
if addr == a.fromaddr {
err := auty.ErrRepeatVoteAddr
alog.Error("votePropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "repeat address GameID",
voteProb.ProposalID, "err", err)
return nil, err
}
} }
// 加入已经投票的 // 更新投票记录
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数 if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数
...@@ -266,11 +226,10 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt ...@@ -266,11 +226,10 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
if cur.VoteResult.Pass { if cur.VoteResult.Pass {
cur.Status = auty.AutonomyStatusTmintPropBoard cur.Status = auty.AutonomyStatusTmintPropBoard
} }
value = types.Encode(&cur) kv = append(kv, &types.KeyValue{Key: key, Value: types.Encode(cur)})
kv = append(kv, &types.KeyValue{Key: key, Value: value})
// 更新VotesRecord // 更新VotesRecord
kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(&votes)}) kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(votes)})
// 更新当前具有权利的董事会成员 // 更新当前具有权利的董事会成员
if cur.VoteResult.Pass { if cur.VoteResult.Pass {
...@@ -281,28 +240,20 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt ...@@ -281,28 +240,20 @@ func (a *action) votePropBoard(voteProb *auty.VoteProposalBoard) (*types.Receipt
if cur.VoteResult.Pass { if cur.VoteResult.Pass {
ty = auty.TyLogTmintPropBoard ty = auty.TyLogTmintPropBoard
} }
receiptLog := getReceiptLog(pre, &cur, int32(ty)) receiptLog := getReceiptLog(pre, cur, int32(ty))
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.Receipt, error) { func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalBoard(tmintProb.ProposalID)
value, err := a.db.Get(propBoardID(tmintProb.ProposalID))
if err != nil {
alog.Error("tmintPropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "get propBoardID failed",
tmintProb.ProposalID, "err", err)
return nil, err
}
var cur auty.AutonomyProposalBoard
err = types.Decode(value, &cur)
if err != nil { if err != nil {
alog.Error("tmintPropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode AutonomyProposalBoard failed", alog.Error("tmintPropBoard ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalBoard failed",
tmintProb.ProposalID, "err", err) tmintProb.ProposalID, "err", err)
return nil, err return nil, err
} }
pre := copyAutonomyProposalBoard(&cur) pre := copyAutonomyProposalBoard(cur)
// 检查当前状态 // 检查当前状态
if cur.Status == auty.AutonomyStatusTmintPropBoard { if cur.Status == auty.AutonomyStatusTmintPropBoard {
...@@ -350,14 +301,14 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types. ...@@ -350,14 +301,14 @@ func (a *action) tmintPropBoard(tmintProb *auty.TerminateProposalBoard) (*types.
cur.Status = auty.AutonomyStatusTmintPropBoard cur.Status = auty.AutonomyStatusTmintPropBoard
kv = append(kv, &types.KeyValue{Key: propBoardID(tmintProb.ProposalID), Value: types.Encode(&cur)}) kv = append(kv, &types.KeyValue{Key: propBoardID(tmintProb.ProposalID), Value: types.Encode(cur)})
// 更新当前具有权利的董事会成员 // 更新当前具有权利的董事会成员
if cur.VoteResult.Pass { if cur.VoteResult.Pass {
kv = append(kv, &types.KeyValue{Key: activeBoardID(), Value:types.Encode(cur.PropBoard)}) kv = append(kv, &types.KeyValue{Key: activeBoardID(), Value:types.Encode(cur.PropBoard)})
} }
getReceiptLog(pre, &cur, auty.TyLogTmintPropBoard) getReceiptLog(pre, cur, auty.TyLogTmintPropBoard)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
...@@ -386,6 +337,57 @@ func (a *action) getStartHeightVoteAccount(addr string, height int64) (*types.Ac ...@@ -386,6 +337,57 @@ func (a *action) getStartHeightVoteAccount(addr string, height int64) (*types.Ac
return account[0], nil return account[0], nil
} }
func (a *action) getProposalBoard(ID string) (*auty.AutonomyProposalBoard, error) {
value, err := a.db.Get(propBoardID(ID))
if err != nil {
return nil, err
}
cur := &auty.AutonomyProposalBoard{}
err = types.Decode(value, cur)
if err != nil {
return nil, err
}
return cur, nil
}
func (a *action) getActiveRule() (*auty.RuleConfig, error) {
// 获取当前生效提案规则,并且将不修改的规则补齐
rule := &auty.RuleConfig{}
value, err := a.db.Get(activeRuleID())
if err == nil {
err = types.Decode(value, rule)
if err != nil {
return nil, err
}
} else {// 载入系统默认值
rule.BoardAttendRatio = boardAttendRatio
rule.BoardApproveRatio = boardApproveRatio
rule.PubOpposeRatio = pubOpposeRatio
rule.ProposalAmount = proposalAmount
rule.LargeProjectAmount = largeProjectAmount
}
return rule, nil
}
func (a *action) checkVotesRecord(ID string) (*auty.VotesRecord, error) {
var votes auty.VotesRecord
value, err := a.db.Get(VotesRecord(ID))
if err == nil {
err = types.Decode(value, &votes)
if err != nil {
return nil, err
}
}
// 检查是否有重复
for _, addr := range votes.Address {
if addr == a.fromaddr {
err := auty.ErrRepeatVoteAddr
return nil, err
}
}
return &votes, nil
}
// getReceiptLog 根据提案信息获取log // getReceiptLog 根据提案信息获取log
// 状态变化: // 状态变化:
func getReceiptLog(pre, cur *auty.AutonomyProposalBoard, ty int32) *types.ReceiptLog { func getReceiptLog(pre, cur *auty.AutonomyProposalBoard, ty int32) *types.ReceiptLog {
......
...@@ -175,7 +175,7 @@ func testPropBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm. ...@@ -175,7 +175,7 @@ func testPropBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB dbm.
accCoin := account.NewCoinsAccount() accCoin := account.NewCoinsAccount()
accCoin.SetDB(stateDB) accCoin.SetDB(stateDB)
account := accCoin.LoadExecAccount(AddrA, address.ExecAddress(auty.AutonomyX)) account := accCoin.LoadExecAccount(AddrA, address.ExecAddress(auty.AutonomyX))
require.Equal(t, lockAmount, account.Frozen) require.Equal(t, proposalAmount, account.Frozen)
} }
func propBoardTx(parm *auty.ProposalBoard) (*types.Transaction, error) { func propBoardTx(parm *auty.ProposalBoard) (*types.Transaction, error) {
...@@ -267,10 +267,10 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB ...@@ -267,10 +267,10 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
appr bool appr bool
} }
records := []record{ records := []record{
{PrivKeyA, true}, {PrivKeyA, false},
{PrivKeyB, false}, {PrivKeyB, false},
{PrivKeyC, true}, {PrivKeyC, true},
//{PrivKeyD, true}, {PrivKeyD, true},
} }
for _, record := range records { for _, record := range records {
...@@ -320,7 +320,7 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB ...@@ -320,7 +320,7 @@ func voteProposalBoard(t *testing.T, env *execEnv, exec drivers.Driver, stateDB
account := accCoin.LoadExecAccount(AddrA, address.ExecAddress(auty.AutonomyX)) account := accCoin.LoadExecAccount(AddrA, address.ExecAddress(auty.AutonomyX))
require.Equal(t, int64(0), account.Frozen) require.Equal(t, int64(0), account.Frozen)
account = accCoin.LoadExecAccount(autonomyAddr, address.ExecAddress(auty.AutonomyX)) account = accCoin.LoadExecAccount(autonomyAddr, address.ExecAddress(auty.AutonomyX))
require.Equal(t, int64(lockAmount), account.Balance) require.Equal(t, int64(proposalAmount), account.Balance)
// status // status
value, err := stateDB.Get(propBoardID(proposalID)) value, err := stateDB.Get(propBoardID(proposalID))
require.NoError(t, err) require.NoError(t, err)
......
...@@ -24,41 +24,18 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error) ...@@ -24,41 +24,18 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error)
} }
// 获取董事会成员 // 获取董事会成员
value, err := a.db.Get(activeBoardID()) pboard, err := a.getActiveBoard()
if err != nil { if err != nil {
err = auty.ErrNoActiveBoard alog.Error("propProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get getActiveBoard failed", err)
alog.Error("propProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get activeBoardID failed", err)
return nil, err return nil, err
} }
pboard := &auty.ProposalBoard{} // 获取当前生效提案规则
err = types.Decode(value, pboard) rule, err := a.getActiveRule()
if err != nil { if err != nil {
alog.Error("propProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode ProposalBoard failed", err) alog.Error("propProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "getActiveRule failed", err)
return nil, err
}
if len(pboard.Boards) > maxBoards || len(pboard.Boards) < minBoards {
err = auty.ErrNoActiveBoard
alog.Error("propProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "illegality boards number", err)
return nil, err return nil, err
} }
// 获取当前生效提案规则,并且将不修改的规则补齐
rule := &auty.RuleConfig{}
value, err = a.db.Get(activeRuleID())
if err == nil {
err = types.Decode(value, rule)
if err != nil {
alog.Error("propProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode ProposalRule failed", err)
return nil, err
}
} else {// 载入系统默认值
rule.BoardAttendRatio = boardAttendRatio
rule.BoardApproveRatio = boardApproveRatio
rule.PubOpposeRatio = pubOpposeRatio
rule.ProposalAmount = proposalAmount
rule.LargeProjectAmount = largeProjectAmount
}
receipt, err := a.coinsAccount.ExecFrozen(a.fromaddr, a.execaddr, rule.ProposalAmount) receipt, err := a.coinsAccount.ExecFrozen(a.fromaddr, a.execaddr, rule.ProposalAmount)
if err != nil { if err != nil {
alog.Error("propProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "ExecFrozen amount", rule.ProposalAmount) alog.Error("propProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "ExecFrozen amount", rule.ProposalAmount)
...@@ -79,7 +56,7 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error) ...@@ -79,7 +56,7 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error)
PropProject:prob, PropProject:prob,
CurRule:rule, CurRule:rule,
Boards: pboard.Boards, Boards: pboard.Boards,
BoardVoteRes: &auty.VoteResult{}, BoardVoteRes: &auty.VoteResult{TotalVotes: int32(len(pboard.Boards))},
PubVote: &auty.PublicVote{Publicity:isPubVote}, PubVote: &auty.PublicVote{Publicity:isPubVote},
Status: auty.AutonomyStatusProposalProject, Status: auty.AutonomyStatusProposalProject,
Address: a.fromaddr, Address: a.fromaddr,
...@@ -94,21 +71,13 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error) ...@@ -94,21 +71,13 @@ func (a *action) propProject(prob *auty.ProposalProject) (*types.Receipt, error)
} }
func (a *action) rvkPropProject(rvkProb *auty.RevokeProposalProject) (*types.Receipt, error) { func (a *action) rvkPropProject(rvkProb *auty.RevokeProposalProject) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalProject(rvkProb.ProposalID)
value, err := a.db.Get(propProjectID(rvkProb.ProposalID))
if err != nil {
alog.Error("rvkPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get ProposalProject) failed",
rvkProb.ProposalID, "err", err)
return nil, err
}
var cur auty.AutonomyProposalProject
err = types.Decode(value, &cur)
if err != nil { if err != nil {
alog.Error("rvkPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode ProposalProject failed", alog.Error("rvkPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalProject failed",
rvkProb.ProposalID, "err", err) rvkProb.ProposalID, "err", err)
return nil, err return nil, err
} }
pre := copyAutonomyProposalProject(&cur) pre := copyAutonomyProposalProject(cur)
// 检查当前状态 // 检查当前状态
if cur.Status != auty.AutonomyStatusProposalProject { if cur.Status != auty.AutonomyStatusProposalProject {
...@@ -146,29 +115,21 @@ func (a *action) rvkPropProject(rvkProb *auty.RevokeProposalProject) (*types.Rec ...@@ -146,29 +115,21 @@ func (a *action) rvkPropProject(rvkProb *auty.RevokeProposalProject) (*types.Rec
cur.Status = auty.AutonomyStatusRvkPropProject cur.Status = auty.AutonomyStatusRvkPropProject
kv = append(kv, &types.KeyValue{Key: propProjectID(rvkProb.ProposalID), Value: types.Encode(&cur)}) kv = append(kv, &types.KeyValue{Key: propProjectID(rvkProb.ProposalID), Value: types.Encode(cur)})
getProjectReceiptLog(pre, &cur, auty.TyLogRvkPropProject) getProjectReceiptLog(pre, cur, auty.TyLogRvkPropProject)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Receipt, error) { func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalProject(voteProb.ProposalID)
value, err := a.db.Get(propProjectID(voteProb.ProposalID))
if err != nil {
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get propProjectID failed",
voteProb.ProposalID, "err", err)
return nil, err
}
var cur auty.AutonomyProposalProject
err = types.Decode(value, &cur)
if err != nil { if err != nil {
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode AutonomyProposalProject failed", alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalProject failed",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
pre := copyAutonomyProposalProject(&cur) pre := copyAutonomyProposalProject(cur)
// 检查当前状态 // 检查当前状态
if cur.Status != auty.AutonomyStatusProposalProject && cur.Status != auty.AutonomyStatusVotePropProject { if cur.Status != auty.AutonomyStatusProposalProject && cur.Status != auty.AutonomyStatusVotePropProject {
...@@ -203,24 +164,13 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -203,24 +164,13 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
} }
// 检查是否已经参与投票 // 检查是否已经参与投票
var votes auty.VotesRecord votes, err := a.checkVotesRecord(voteProb.ProposalID)
value, err = a.db.Get(VotesRecord(voteProb.ProposalID)) if err != nil {
if err == nil { alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "checkVotesRecord failed",
err = types.Decode(value, &votes) voteProb.ProposalID, "err", err)
if err != nil { return nil, err
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode VotesRecord failed",
voteProb.ProposalID, "err", err)
return nil, err
}
}
for _, addr := range votes.Address {
if addr == a.fromaddr {
err := auty.ErrRepeatVoteAddr
alog.Error("votePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "repeat address ProposalID",
voteProb.ProposalID, "err", err)
return nil, err
}
} }
// 更新已经投票地址 // 更新已经投票地址
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
// 更新投票结果 // 更新投票结果
...@@ -268,11 +218,10 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -268,11 +218,10 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
kv = append(kv, receipt.KV...) kv = append(kv, receipt.KV...)
} }
} }
value = types.Encode(&cur) kv = append(kv, &types.KeyValue{Key: key, Value: types.Encode(cur)})
kv = append(kv, &types.KeyValue{Key: key, Value: value})
// 更新VotesRecord // 更新VotesRecord
kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(&votes)}) kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(votes)})
ty := auty.TyLogVotePropProject ty := auty.TyLogVotePropProject
if cur.BoardVoteRes.Pass { if cur.BoardVoteRes.Pass {
...@@ -282,28 +231,20 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec ...@@ -282,28 +231,20 @@ func (a *action) votePropProject(voteProb *auty.VoteProposalProject) (*types.Rec
ty = auty.TyLogTmintPropProject ty = auty.TyLogTmintPropProject
} }
} }
receiptLog := getProjectReceiptLog(pre, &cur, int32(ty)) receiptLog := getProjectReceiptLog(pre, cur, int32(ty))
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*types.Receipt, error) { func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalProject(voteProb.ProposalID)
value, err := a.db.Get(propProjectID(voteProb.ProposalID))
if err != nil { if err != nil {
alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get propProjectID failed", alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalProject failed",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
var cur auty.AutonomyProposalProject pre := copyAutonomyProposalProject(cur)
err = types.Decode(value, &cur)
if err != nil {
alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode AutonomyProposalProject failed",
voteProb.ProposalID, "err", err)
return nil, err
}
pre := copyAutonomyProposalProject(&cur)
// 检查当前状态 // 检查当前状态
if cur.Status != auty.AutonomyStatusPubVotePropProject { if cur.Status != auty.AutonomyStatusPubVotePropProject {
...@@ -324,25 +265,13 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ ...@@ -324,25 +265,13 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
} }
// 检查是否已经参与投票 // 检查是否已经参与投票
var votes auty.VotesRecord votes, err := a.checkVotesRecord(voteProb.ProposalID)
value, err = a.db.Get(VotesRecord(voteProb.ProposalID)) if err != nil {
if err == nil { alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "checkVotesRecord failed",
err = types.Decode(value, &votes) voteProb.ProposalID, "err", err)
if err != nil { return nil, err
alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode VotesRecord failed",
voteProb.ProposalID, "err", err)
return nil, err
}
}
for _, addr := range votes.Address {
if addr == a.fromaddr {
err := auty.ErrRepeatVoteAddr
alog.Error("pubVotePropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "repeat address GameID",
voteProb.ProposalID, "err", err)
return nil, err
}
} }
// 加入已经投票的 // 更新投票记录
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
if cur.GetBoardVoteRes().TotalVotes == 0 { //需要统计总票数 if cur.GetBoardVoteRes().TotalVotes == 0 { //需要统计总票数
...@@ -387,34 +316,25 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ ...@@ -387,34 +316,25 @@ func (a *action) pubVotePropProject(voteProb *auty.PubVoteProposalProject) (*typ
cur.Status = auty.AutonomyStatusTmintPropProject cur.Status = auty.AutonomyStatusTmintPropProject
ty = auty.TyLogTmintPropProject ty = auty.TyLogTmintPropProject
} }
value = types.Encode(&cur) kv = append(kv, &types.KeyValue{Key: key, Value: types.Encode(cur)})
kv = append(kv, &types.KeyValue{Key: key, Value: value})
// 更新VotesRecord // 更新VotesRecord
kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(&votes)}) kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(votes)})
receiptLog := getProjectReceiptLog(pre, &cur, int32(ty)) receiptLog := getProjectReceiptLog(pre, cur, int32(ty))
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*types.Receipt, error) { func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalProject(tmintProb.ProposalID)
value, err := a.db.Get(propProjectID(tmintProb.ProposalID))
if err != nil { if err != nil {
alog.Error("tmintPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get propProjectID failed", alog.Error("tmintPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalProject failed",
tmintProb.ProposalID, "err", err) tmintProb.ProposalID, "err", err)
return nil, err return nil, err
} }
var cur auty.AutonomyProposalProject pre := copyAutonomyProposalProject(cur)
err = types.Decode(value, &cur)
if err != nil {
alog.Error("tmintPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode AutonomyProposalProject failed",
tmintProb.ProposalID, "err", err)
return nil, err
}
pre := copyAutonomyProposalProject(&cur)
// 检查当前状态 // 检查当前状态
if cur.Status == auty.AutonomyStatusTmintPropProject { if cur.Status == auty.AutonomyStatusTmintPropProject {
...@@ -443,31 +363,6 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty ...@@ -443,31 +363,6 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
return nil, err return nil, err
} }
if cur.GetBoardVoteRes().TotalVotes == 0 { //需要统计票数
// 董事会成员验证
value, err = a.db.Get(activeBoardID())
if err != nil {
err = auty.ErrNoActiveBoard
alog.Error("tmintPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "get activeBoardID failed",
tmintProb.ProposalID, "err", err)
return nil, err
}
prob := &auty.ProposalBoard{}
err = types.Decode(value, prob)
if err != nil {
alog.Error("tmintPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode ProposalBoard failed",
tmintProb.ProposalID, "err", err)
return nil, err
}
if len(prob.Boards) > maxBoards || len(prob.Boards) < minBoards {
err = auty.ErrNoActiveBoard
alog.Error("tmintPropProject ", "addr", a.fromaddr, "execaddr", a.execaddr, "illegality boards number",
tmintProb.ProposalID, "err", err)
return nil, err
}
cur.BoardVoteRes.TotalVotes = int32(len(prob.Boards))
}
if cur.BoardVoteRes.TotalVotes != 0 && if cur.BoardVoteRes.TotalVotes != 0 &&
cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes != 0 && cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes != 0 &&
float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) / float32(cur.BoardVoteRes.TotalVotes) >= float32(cur.CurRule.BoardAttendRatio)/100.0 && float32(cur.BoardVoteRes.ApproveVotes + cur.BoardVoteRes.OpposeVotes) / float32(cur.BoardVoteRes.TotalVotes) >= float32(cur.CurRule.BoardAttendRatio)/100.0 &&
...@@ -518,13 +413,43 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty ...@@ -518,13 +413,43 @@ func (a *action) tmintPropProject(tmintProb *auty.TerminateProposalProject) (*ty
cur.Status = auty.AutonomyStatusTmintPropProject cur.Status = auty.AutonomyStatusTmintPropProject
kv = append(kv, &types.KeyValue{Key: propProjectID(tmintProb.ProposalID), Value: types.Encode(&cur)}) kv = append(kv, &types.KeyValue{Key: propProjectID(tmintProb.ProposalID), Value: types.Encode(cur)})
getProjectReceiptLog(pre, &cur, auty.TyLogTmintPropProject) getProjectReceiptLog(pre, cur, auty.TyLogTmintPropProject)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
func (a *action) getProposalProject(ID string) (*auty.AutonomyProposalProject, error) {
value, err := a.db.Get(propProjectID(ID))
if err != nil {
return nil, err
}
cur := &auty.AutonomyProposalProject{}
err = types.Decode(value, cur)
if err != nil {
return nil, err
}
return cur, nil
}
func (a *action) getActiveBoard() (*auty.ProposalBoard, error) {
value, err := a.db.Get(activeBoardID())
if err != nil {
return nil, err
}
pboard := &auty.ProposalBoard{}
err = types.Decode(value, pboard)
if err != nil {
return nil, err
}
if len(pboard.Boards) > maxBoards || len(pboard.Boards) < minBoards {
err = auty.ErrNoActiveBoard
return nil, err
}
return pboard, nil
}
// getProjectReceiptLog 根据提案信息获取log // getProjectReceiptLog 根据提案信息获取log
// 状态变化: // 状态变化:
func getProjectReceiptLog(pre, cur *auty.AutonomyProposalProject, ty int32) *types.ReceiptLog { func getProjectReceiptLog(pre, cur *auty.AutonomyProposalProject, ty int32) *types.ReceiptLog {
......
...@@ -25,21 +25,12 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) { ...@@ -25,21 +25,12 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) {
} }
// 获取当前生效提案规则,并且将不修改的规则补齐 // 获取当前生效提案规则,并且将不修改的规则补齐
rule := &auty.RuleConfig{} rule, err := a.getActiveRule()
value, err := a.db.Get(activeRuleID()) if err != nil {
if err == nil { alog.Error("propRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "getActiveRule failed", err)
err = types.Decode(value, rule) return nil, err
if err != nil {
alog.Error("propRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode ProposalRule failed", err)
return nil, err
}
} else {// 载入系统默认值
rule.BoardAttendRatio = boardAttendRatio
rule.BoardApproveRatio = boardApproveRatio
rule.PubOpposeRatio = pubOpposeRatio
rule.ProposalAmount = proposalAmount
rule.LargeProjectAmount = largeProjectAmount
} }
if prob.RuleCfg.BoardAttendRatio > 0 { if prob.RuleCfg.BoardAttendRatio > 0 {
rule.BoardAttendRatio = prob.RuleCfg.BoardAttendRatio rule.BoardAttendRatio = prob.RuleCfg.BoardAttendRatio
} }
...@@ -79,7 +70,7 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) { ...@@ -79,7 +70,7 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) {
} }
key := propRuleID(common.ToHex(a.txhash)) key := propRuleID(common.ToHex(a.txhash))
value = types.Encode(cur) value := types.Encode(cur)
kv = append(kv, &types.KeyValue{Key: key, Value: value}) kv = append(kv, &types.KeyValue{Key: key, Value: value})
receiptLog := getRuleReceiptLog(nil, cur, auty.TyLogPropRule) receiptLog := getRuleReceiptLog(nil, cur, auty.TyLogPropRule)
...@@ -89,21 +80,13 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) { ...@@ -89,21 +80,13 @@ func (a *action) propRule(prob *auty.ProposalRule) (*types.Receipt, error) {
} }
func (a *action) rvkPropRule(rvkProb *auty.RevokeProposalRule) (*types.Receipt, error) { func (a *action) rvkPropRule(rvkProb *auty.RevokeProposalRule) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalRule(rvkProb.ProposalID)
value, err := a.db.Get(propRuleID(rvkProb.ProposalID))
if err != nil {
alog.Error("rvkPropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "get ProposalRule) failed",
rvkProb.ProposalID, "err", err)
return nil, err
}
var cur auty.AutonomyProposalRule
err = types.Decode(value, &cur)
if err != nil { if err != nil {
alog.Error("rvkPropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode ProposalRule failed", alog.Error("rvkPropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalRule failed",
rvkProb.ProposalID, "err", err) rvkProb.ProposalID, "err", err)
return nil, err return nil, err
} }
pre := copyAutonomyProposalRule(&cur) pre := copyAutonomyProposalRule(cur)
// 检查当前状态 // 检查当前状态
if cur.Status != auty.AutonomyStatusProposalRule { if cur.Status != auty.AutonomyStatusProposalRule {
...@@ -141,29 +124,21 @@ func (a *action) rvkPropRule(rvkProb *auty.RevokeProposalRule) (*types.Receipt, ...@@ -141,29 +124,21 @@ func (a *action) rvkPropRule(rvkProb *auty.RevokeProposalRule) (*types.Receipt,
cur.Status = auty.AutonomyStatusRvkPropRule cur.Status = auty.AutonomyStatusRvkPropRule
kv = append(kv, &types.KeyValue{Key: propRuleID(rvkProb.ProposalID), Value: types.Encode(&cur)}) kv = append(kv, &types.KeyValue{Key: propRuleID(rvkProb.ProposalID), Value: types.Encode(cur)})
getRuleReceiptLog(pre, &cur, auty.TyLogRvkPropRule) getRuleReceiptLog(pre, cur, auty.TyLogRvkPropRule)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, error) { func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalRule(voteProb.ProposalID)
value, err := a.db.Get(propRuleID(voteProb.ProposalID))
if err != nil { if err != nil {
alog.Error("votePropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "get propRuleID failed", alog.Error("votePropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalRule failed",
voteProb.ProposalID, "err", err) voteProb.ProposalID, "err", err)
return nil, err return nil, err
} }
var cur auty.AutonomyProposalRule pre := copyAutonomyProposalRule(cur)
err = types.Decode(value, &cur)
if err != nil {
alog.Error("votePropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode AutonomyProposalRule failed",
voteProb.ProposalID, "err", err)
return nil, err
}
pre := copyAutonomyProposalRule(&cur)
// 检查当前状态 // 检查当前状态
if cur.Status != auty.AutonomyStatusProposalRule && cur.Status != auty.AutonomyStatusVotePropRule { if cur.Status != auty.AutonomyStatusProposalRule && cur.Status != auty.AutonomyStatusVotePropRule {
...@@ -184,27 +159,13 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, ...@@ -184,27 +159,13 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
} }
// 检查是否已经参与投票 // 检查是否已经参与投票
var votes auty.VotesRecord votes, err := a.checkVotesRecord(voteProb.ProposalID)
value, err = a.db.Get(VotesRecord(voteProb.ProposalID)) if err != nil {
if err == nil { alog.Error("votePropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "checkVotesRecord failed",
err = types.Decode(value, &votes) voteProb.ProposalID, "err", err)
if err != nil { return nil, err
alog.Error("votePropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode VotesRecord failed",
voteProb.ProposalID, "err", err)
return nil, err
}
}
// 检查是否有重复
for _, addr := range votes.Address {
if addr == a.fromaddr {
err := auty.ErrRepeatVoteAddr
alog.Error("votePropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "repeat address GameID",
voteProb.ProposalID, "err", err)
return nil, err
}
} }
// 加入已经投票的 // 更新投票记录
votes.Address = append(votes.Address, a.fromaddr) votes.Address = append(votes.Address, a.fromaddr)
if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数 if cur.GetVoteResult().TotalVotes == 0 { //需要统计票数
...@@ -216,6 +177,7 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, ...@@ -216,6 +177,7 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
cur.VoteResult.TotalVotes = int32(account.Balance/ticketPrice) cur.VoteResult.TotalVotes = int32(account.Balance/ticketPrice)
} }
// 获取可投票数
account, err := a.getStartHeightVoteAccount(a.fromaddr, start) account, err := a.getStartHeightVoteAccount(a.fromaddr, start)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -250,13 +212,12 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, ...@@ -250,13 +212,12 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
if cur.VoteResult.Pass { if cur.VoteResult.Pass {
cur.Status = auty.AutonomyStatusTmintPropRule cur.Status = auty.AutonomyStatusTmintPropRule
} }
value = types.Encode(&cur) kv = append(kv, &types.KeyValue{Key: key, Value: types.Encode(cur)})
kv = append(kv, &types.KeyValue{Key: key, Value: value})
// 更新VotesRecord // 更新VotesRecord
kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(&votes)}) kv = append(kv, &types.KeyValue{Key: VotesRecord(voteProb.ProposalID), Value: types.Encode(votes)})
// 更新当前具有权利的董事会成员 // 更新系统规则
if cur.VoteResult.Pass { if cur.VoteResult.Pass {
kv = append(kv, &types.KeyValue{Key: activeRuleID(), Value:types.Encode(cur.Rule)}) kv = append(kv, &types.KeyValue{Key: activeRuleID(), Value:types.Encode(cur.Rule)})
} }
...@@ -265,28 +226,21 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt, ...@@ -265,28 +226,21 @@ func (a *action) votePropRule(voteProb *auty.VoteProposalRule) (*types.Receipt,
if cur.VoteResult.Pass { if cur.VoteResult.Pass {
ty = auty.TyLogTmintPropRule ty = auty.TyLogTmintPropRule
} }
receiptLog := getRuleReceiptLog(pre, &cur, int32(ty)) receiptLog := getRuleReceiptLog(pre, cur, int32(ty))
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Receipt, error) { func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Receipt, error) {
// 获取GameID cur, err := a.getProposalRule(tmintProb.ProposalID)
value, err := a.db.Get(propRuleID(tmintProb.ProposalID))
if err != nil {
alog.Error("tmintPropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "get propRuleID failed",
tmintProb.ProposalID, "err", err)
return nil, err
}
var cur auty.AutonomyProposalRule
err = types.Decode(value, &cur)
if err != nil { if err != nil {
alog.Error("tmintPropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "decode AutonomyProposalRule failed", alog.Error("tmintPropRule ", "addr", a.fromaddr, "execaddr", a.execaddr, "getProposalRule failed",
tmintProb.ProposalID, "err", err) tmintProb.ProposalID, "err", err)
return nil, err return nil, err
} }
pre := copyAutonomyProposalRule(&cur)
pre := copyAutonomyProposalRule(cur)
// 检查当前状态 // 检查当前状态
if cur.Status == auty.AutonomyStatusTmintPropRule { if cur.Status == auty.AutonomyStatusTmintPropRule {
...@@ -334,18 +288,31 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re ...@@ -334,18 +288,31 @@ func (a *action) tmintPropRule(tmintProb *auty.TerminateProposalRule) (*types.Re
cur.Status = auty.AutonomyStatusTmintPropRule cur.Status = auty.AutonomyStatusTmintPropRule
kv = append(kv, &types.KeyValue{Key: propRuleID(tmintProb.ProposalID), Value: types.Encode(&cur)}) kv = append(kv, &types.KeyValue{Key: propRuleID(tmintProb.ProposalID), Value: types.Encode(cur)})
// 更新当前具有权利的董事会成员 // 更新系统规则
if cur.VoteResult.Pass { if cur.VoteResult.Pass {
kv = append(kv, &types.KeyValue{Key: activeRuleID(), Value:types.Encode(cur.Rule)}) kv = append(kv, &types.KeyValue{Key: activeRuleID(), Value:types.Encode(cur.Rule)})
} }
getRuleReceiptLog(pre, &cur, auty.TyLogTmintPropRule) getRuleReceiptLog(pre, cur, auty.TyLogTmintPropRule)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
func (a *action) getProposalRule(ID string) (*auty.AutonomyProposalRule, error) {
value, err := a.db.Get(propRuleID(ID))
if err != nil {
return nil, err
}
cur := &auty.AutonomyProposalRule{}
err = types.Decode(value, cur)
if err != nil {
return nil, err
}
return cur, nil
}
// getReceiptLog 根据提案信息获取log // getReceiptLog 根据提案信息获取log
// 状态变化: // 状态变化:
func getRuleReceiptLog(pre, cur *auty.AutonomyProposalRule, ty int32) *types.ReceiptLog { func getRuleReceiptLog(pre, cur *auty.AutonomyProposalRule, ty int32) *types.ReceiptLog {
......
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