mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-22 17:31:34 +00:00
fixed global flags
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
btypes "github.com/tendermint/tendermint/cmd/barak/types"
|
||||
@ -8,13 +9,33 @@ import (
|
||||
"github.com/tendermint/tendermint/rpc"
|
||||
)
|
||||
|
||||
// Convenience function for a single validator.
|
||||
func ListProcesses(privKey acm.PrivKey, remote string) (btypes.ResponseListProcesses, error) {
|
||||
command := btypes.CommandListProcesses{}
|
||||
nonce := GetNonce(remote)
|
||||
func RunProcess(privKey acm.PrivKey, remote string, command btypes.CommandRunProcess) (response btypes.ResponseRunProcess, err error) {
|
||||
nonce, err := GetNonce(remote)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
commandBytes, signature := SignCommand(privKey, nonce+1, command)
|
||||
response := btypes.ResponseListProcesses{}
|
||||
_, err := RunAuthCommand(remote, commandBytes, []acm.Signature{signature}, &response)
|
||||
_, err = RunAuthCommand(remote, commandBytes, []acm.Signature{signature}, &response)
|
||||
return response, err
|
||||
}
|
||||
|
||||
func StopProcess(privKey acm.PrivKey, remote string, command btypes.CommandStopProcess) (response btypes.ResponseStopProcess, err error) {
|
||||
nonce, err := GetNonce(remote)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
commandBytes, signature := SignCommand(privKey, nonce+1, command)
|
||||
_, err = RunAuthCommand(remote, commandBytes, []acm.Signature{signature}, &response)
|
||||
return response, err
|
||||
}
|
||||
|
||||
func ListProcesses(privKey acm.PrivKey, remote string, command btypes.CommandListProcesses) (response btypes.ResponseListProcesses, err error) {
|
||||
nonce, err := GetNonce(remote)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
commandBytes, signature := SignCommand(privKey, nonce+1, command)
|
||||
_, err = RunAuthCommand(remote, commandBytes, []acm.Signature{signature}, &response)
|
||||
return response, err
|
||||
}
|
||||
|
||||
@ -22,14 +43,14 @@ func ListProcesses(privKey acm.PrivKey, remote string) (btypes.ResponseListProce
|
||||
|
||||
// Utility method to get nonce from the remote.
|
||||
// The next command should include the returned nonce+1 as nonce.
|
||||
func GetNonce(remote string) uint64 {
|
||||
func GetNonce(remote string) (uint64, error) {
|
||||
var err error
|
||||
response := btypes.ResponseStatus{}
|
||||
_, err = rpc.Call(remote, "status", Arr(), &response)
|
||||
if err != nil {
|
||||
Exit(Fmt("Error fetching nonce from remote %v: %v", remote, err))
|
||||
return 0, fmt.Errorf("Error fetching nonce from remote %v:\n %v", remote, err)
|
||||
}
|
||||
return response.Nonce
|
||||
return response.Nonce, nil
|
||||
}
|
||||
|
||||
// Each developer runs this
|
||||
|
Reference in New Issue
Block a user