• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revisioncbf22dda4fe8270e7f5b61d15a771638776257a9 (tree)
Time2019-07-17 10:28:25
Authorshenao78 <shenao.78@163....>
Commitershenao78

Log Message

ten times federation vote

Change Summary

Incremental Difference

--- a/protocol/state/consensus_result.go
+++ b/protocol/state/consensus_result.go
@@ -108,6 +108,8 @@ func (c *ConsensusResult) ApplyBlock(block *types.Block) error {
108108 return err
109109 }
110110
111+ federationProgram := hex.EncodeToString(config.FederationWScript(config.CommonConfig))
112+
111113 for _, tx := range block.Transactions {
112114 for _, input := range tx.Inputs {
113115 vetoInput, ok := input.TypedInput.(*types.VetoInput)
@@ -115,6 +117,10 @@ func (c *ConsensusResult) ApplyBlock(block *types.Block) error {
115117 continue
116118 }
117119
120+ if federationProgram == hex.EncodeToString(vetoInput.ControlProgram) {
121+ vetoInput.Amount = vetoInput.Amount * 10
122+ }
123+
118124 pubkey := hex.EncodeToString(vetoInput.Vote)
119125 c.NumOfVote[pubkey], ok = checked.SubUint64(c.NumOfVote[pubkey], vetoInput.Amount)
120126 if !ok {
@@ -132,6 +138,10 @@ func (c *ConsensusResult) ApplyBlock(block *types.Block) error {
132138 continue
133139 }
134140
141+ if federationProgram == hex.EncodeToString(voteOutput.ControlProgram) {
142+ voteOutput.Amount = voteOutput.Amount * 10
143+ }
144+
135145 pubkey := hex.EncodeToString(voteOutput.Vote)
136146 if c.NumOfVote[pubkey], ok = checked.AddUint64(c.NumOfVote[pubkey], voteOutput.Amount); !ok {
137147 return checked.ErrOverflow
@@ -203,6 +213,8 @@ func (c *ConsensusResult) DetachBlock(block *types.Block) error {
203213 return err
204214 }
205215
216+ federationProgram := hex.EncodeToString(config.FederationWScript(config.CommonConfig))
217+
206218 for i := len(block.Transactions) - 1; i >= 0; i-- {
207219 tx := block.Transactions[i]
208220 for _, input := range tx.Inputs {
@@ -211,6 +223,10 @@ func (c *ConsensusResult) DetachBlock(block *types.Block) error {
211223 continue
212224 }
213225
226+ if federationProgram == hex.EncodeToString(vetoInput.ControlProgram) {
227+ vetoInput.Amount = vetoInput.Amount * 10
228+ }
229+
214230 pubkey := hex.EncodeToString(vetoInput.Vote)
215231 if c.NumOfVote[pubkey], ok = checked.AddUint64(c.NumOfVote[pubkey], vetoInput.Amount); !ok {
216232 return checked.ErrOverflow
@@ -223,6 +239,10 @@ func (c *ConsensusResult) DetachBlock(block *types.Block) error {
223239 continue
224240 }
225241
242+ if federationProgram == hex.EncodeToString(voteOutput.ControlProgram) {
243+ voteOutput.Amount = voteOutput.Amount * 10
244+ }
245+
226246 pubkey := hex.EncodeToString(voteOutput.Vote)
227247 c.NumOfVote[pubkey], ok = checked.SubUint64(c.NumOfVote[pubkey], voteOutput.Amount)
228248 if !ok {
Show on old repository browser