Skip to content

Commit

Permalink
fix qbft cmd: fix paraName param
Browse files Browse the repository at this point in the history
  • Loading branch information
linj-disanbo committed Feb 5, 2024
1 parent 0bd1fd2 commit ab0843a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion plugin/dapp/qbftNode/commands/qbftNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"os"
"strconv"
"time"
"strings"

pt "github.com/assetcloud/plugin/plugin/dapp/paracross/types"
"github.com/assetcloud/chain/common/address"

"github.com/assetcloud/chain/common/crypto"
Expand Down Expand Up @@ -223,13 +225,15 @@ func addNodeFlags(cmd *cobra.Command) {
func addNode(cmd *cobra.Command, args []string) {
pubkey, _ := cmd.Flags().GetString("pubkey")
power, _ := cmd.Flags().GetInt64("power")
paraName, _ := cmd.Flags().GetString("paraName")
execer := getRealExecName(paraName, vt.QbftNodeX)

value := &vt.QbftNodeAction_Node{Node: &vt.QbftNode{PubKey: pubkey, Power: power}}
action := &vt.QbftNodeAction{Value: value, Ty: vt.QbftNodeActionUpdate}
tx := &types.Transaction{
Payload: types.Encode(action),
Nonce: rand.Int63(),
Execer: []byte(vt.QbftNodeX),
Execer: []byte(execer),
}
tx.To = address.ExecAddress(string(tx.Execer))

Expand Down Expand Up @@ -337,3 +341,10 @@ func createFiles(cmd *cobra.Command, args []string) {
}
fmt.Printf("generate genesis file path %v\n", genFile)
}

func getRealExecName(paraName string, name string) string {
if strings.HasPrefix(name, pt.ParaPrefix) {
return name
}
return paraName + name
}

0 comments on commit ab0843a

Please sign in to comment.