OSDN Git Service

rename unvote to veto (#191)
authorwz <mars@bytom.io>
Wed, 19 Jun 2019 05:40:32 +0000 (13:40 +0800)
committerPaladz <yzhu101@uottawa.ca>
Wed, 19 Jun 2019 05:40:32 +0000 (13:40 +0800)
account/builder.go
api/transact.go
docs/vote/read.md
protocol/bc/types/txinput.go
protocol/bc/types/txinput_test.go
protocol/bc/types/veto_input.go
protocol/state/vote_result.go

index fe96d74..5f2448a 100644 (file)
@@ -386,13 +386,13 @@ func (m *Manager) insertControlProgramDelayed(b *txbuilder.TemplateBuilder, acp
        })
 }
 
-//DecodeUnvoteAction unmarshal JSON-encoded data of spend action
-func (m *Manager) DecodeUnvoteAction(data []byte) (txbuilder.Action, error) {
-       a := &unvoteAction{accounts: m}
+//DecodeVetoAction unmarshal JSON-encoded data of spend action
+func (m *Manager) DecodeVetoAction(data []byte) (txbuilder.Action, error) {
+       a := &vetoAction{accounts: m}
        return a, stdjson.Unmarshal(data, a)
 }
 
-type unvoteAction struct {
+type vetoAction struct {
        accounts *Manager
        bc.AssetAmount
        AccountID      string        `json:"account_id"`
@@ -400,11 +400,11 @@ type unvoteAction struct {
        UseUnconfirmed bool          `json:"use_unconfirmed"`
 }
 
-func (a *unvoteAction) ActionType() string {
-       return "unvote"
+func (a *vetoAction) ActionType() string {
+       return "veto"
 }
 
-func (a *unvoteAction) Build(ctx context.Context, b *txbuilder.TemplateBuilder) error {
+func (a *vetoAction) Build(ctx context.Context, b *txbuilder.TemplateBuilder) error {
        var missing []string
        if a.AccountID == "" {
                missing = append(missing, "account_id")
index 3f2c0db..76e6d53 100644 (file)
@@ -31,7 +31,7 @@ func (a *API) actionDecoder(action string) (func([]byte) (txbuilder.Action, erro
                "cross_chain_in":               txbuilder.DecodeCrossInAction,
                "spend_account":                a.wallet.AccountMgr.DecodeSpendAction,
                "spend_account_unspent_output": a.wallet.AccountMgr.DecodeSpendUTXOAction,
-               "unvote":                       a.wallet.AccountMgr.DecodeUnvoteAction,
+               "veto":                         a.wallet.AccountMgr.DecodeVetoAction,
        }
        decoder, ok := decoders[action]
        return decoder, ok
index 4c97af6..2783be2 100644 (file)
@@ -35,13 +35,13 @@ curl -X POST http://ip:port/build-transaction -d '{"base_transaction":null,"acti
 Example
 
 ```shell
-curl -X POST http://ip:port/build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"0BF63M2U00A04","amount":20000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"account_id":"0BF63M2U00A04","amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","vote":"af594006a40837d9f028daabb6d589df0b9138daefad5683e5233c2646279217294a8d532e60863bcf196625a35fb8ceeffa3c09610eb92dcfb655a947f13269","type":"unvote"},{"amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","address":"bm1q50u3z8empm5ke0g3ngl2t3sqtr6sd7cepd3z68","type":"control_address"}],"ttl":0,"time_range": 43432}'
+curl -X POST http://ip:port/build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"0BF63M2U00A04","amount":20000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"account_id":"0BF63M2U00A04","amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","vote":"af594006a40837d9f028daabb6d589df0b9138daefad5683e5233c2646279217294a8d532e60863bcf196625a35fb8ceeffa3c09610eb92dcfb655a947f13269","type":"veto"},{"amount":99,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","address":"bm1q50u3z8empm5ke0g3ngl2t3sqtr6sd7cepd3z68","type":"control_address"}],"ttl":0,"time_range": 43432}'
 ```
 
 以上实例中:
 
 第一个action的type:spend_account 是手续费
 
-第二个action的type:unvote  取消投票,vote 被取消投票的公钥
+第二个action的type:veto  取消投票,vote 被取消投票的公钥
 
 第三个action的type:control_address 还是以前的输出
\ No newline at end of file
index 4918841..888c942 100644 (file)
@@ -180,7 +180,7 @@ func (t *TxInput) readFrom(r *blockchain.Reader) (err error) {
                case VetoInputType:
                        ui := new(VetoInput)
                        t.TypedInput = ui
-                       if ui.UnvoteCommitmentSuffix, err = ui.SpendCommitment.readFrom(r, 1); err != nil {
+                       if ui.VetoCommitmentSuffix, err = ui.SpendCommitment.readFrom(r, 1); err != nil {
 
                                return err
                        }
@@ -286,7 +286,7 @@ func (t *TxInput) writeInputCommitment(w io.Writer) (err error) {
                if _, err = w.Write([]byte{VetoInputType}); err != nil {
                        return err
                }
-               return inp.SpendCommitment.writeExtensibleString(w, inp.UnvoteCommitmentSuffix, t.AssetVersion)
+               return inp.SpendCommitment.writeExtensibleString(w, inp.VetoCommitmentSuffix, t.AssetVersion)
        }
        return nil
 }
index 419b3cd..c590ce6 100644 (file)
@@ -125,7 +125,7 @@ func TestSerializationCrossIn(t *testing.T) {
        }
 }
 
-func TestSerializationUnvote(t *testing.T) {
+func TestSerializationVeto(t *testing.T) {
        arguments := [][]byte{
                []byte("arguments1"),
                []byte("arguments2"),
@@ -136,15 +136,15 @@ func TestSerializationUnvote(t *testing.T) {
        wantHex := strings.Join([]string{
                "01", // asset version
                "54", // input commitment length
-               "03", // unvote type flag
-               "52", // unvote commitment length
+               "03", // veto type flag
+               "52", // veto commitment length
                "fad5195a0c8e3b590b86a3c0a95e7529565888508aecca96e9aeda633002f409", // source id
                "fe9791d71b67ee62515e08723c061b5ccb952a80d804417c8aeedf7f633c524a", // assetID
                "92c30f",                   // amount
                "03",                       // source position
                "01",                       // vm version
-               "0c",                       // unvote program length
-               "7370656e6450726f6772616d", // unvote program
+               "0c",                       // veto program length
+               "7370656e6450726f6772616d", // veto program
                "9901",                     // witness length
                "02",                       // argument array length
                "0a",                       // first argument length
index 59517bd..548310f 100644 (file)
@@ -4,11 +4,11 @@ import (
        "github.com/vapor/protocol/bc"
 )
 
-// VetoInput satisfies the TypedInput interface and represents a unvote transaction.
+// VetoInput satisfies the TypedInput interface and represents a veto transaction.
 type VetoInput struct {
-       UnvoteCommitmentSuffix []byte   // The unconsumed suffix of the output commitment
-       Arguments              [][]byte // Witness
-       Vote                   []byte   // voter xpub
+       VetoCommitmentSuffix []byte   // The unconsumed suffix of the output commitment
+       Arguments            [][]byte // Witness
+       Vote                 []byte   // voter xpub
        SpendCommitment
 }
 
index 96ae36f..6a434c8 100644 (file)
@@ -58,13 +58,13 @@ func (v *VoteResult) ApplyBlock(block *types.Block) error {
 
        for _, tx := range block.Transactions {
                for _, input := range tx.Inputs {
-                       unVoteInput, ok := input.TypedInput.(*types.VetoInput)
+                       vetoInput, ok := input.TypedInput.(*types.VetoInput)
                        if !ok {
                                continue
                        }
 
-                       pubkey := hex.EncodeToString(unVoteInput.Vote)
-                       v.NumOfVote[pubkey], ok = checked.SubUint64(v.NumOfVote[pubkey], unVoteInput.Amount)
+                       pubkey := hex.EncodeToString(vetoInput.Vote)
+                       v.NumOfVote[pubkey], ok = checked.SubUint64(v.NumOfVote[pubkey], vetoInput.Amount)
                        if !ok {
                                return errVotingOperationOverFlow
                        }
@@ -136,13 +136,13 @@ func (v *VoteResult) DetachBlock(block *types.Block) error {
        for i := len(block.Transactions) - 1; i >= 0; i-- {
                tx := block.Transactions[i]
                for _, input := range tx.Inputs {
-                       unVoteInput, ok := input.TypedInput.(*types.VetoInput)
+                       vetoInput, ok := input.TypedInput.(*types.VetoInput)
                        if !ok {
                                continue
                        }
 
-                       pubkey := hex.EncodeToString(unVoteInput.Vote)
-                       if v.NumOfVote[pubkey], ok = checked.AddUint64(v.NumOfVote[pubkey], unVoteInput.Amount); !ok {
+                       pubkey := hex.EncodeToString(vetoInput.Vote)
+                       if v.NumOfVote[pubkey], ok = checked.AddUint64(v.NumOfVote[pubkey], vetoInput.Amount); !ok {
                                return errVotingOperationOverFlow
                        }
                }