Removed a whole lot of old crud
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
)
|
||||
|
||||
type plugin struct {
|
||||
name string
|
||||
newPlugin func() types.Plugin
|
||||
}
|
||||
|
||||
var plugins = []plugin{}
|
||||
|
||||
// RegisterStartPlugin - used to enable a plugin
|
||||
func RegisterStartPlugin(name string, newPlugin func() types.Plugin) {
|
||||
plugins = append(plugins, plugin{name: name, newPlugin: newPlugin})
|
||||
}
|
||||
|
||||
// QuickVersionCmd - returns a version command based on version input
|
||||
func QuickVersionCmd(version string) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Show version info",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println(version)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,6 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
|
||||
"github.com/tendermint/basecoin/types"
|
||||
|
||||
client "github.com/tendermint/tendermint/rpc/client"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
)
|
||||
import "encoding/hex"
|
||||
|
||||
// Returns true for non-empty hex-string prefixed with "0x"
|
||||
func isHex(s string) bool {
|
||||
@@ -34,77 +21,3 @@ func StripHex(s string) string {
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Query - send an abci query
|
||||
func Query(tmAddr string, key []byte) (*abci.ResultQuery, error) {
|
||||
httpClient := client.NewHTTP(tmAddr, "/websocket")
|
||||
return queryWithClient(httpClient, key)
|
||||
}
|
||||
|
||||
func queryWithClient(httpClient *client.HTTP, key []byte) (*abci.ResultQuery, error) {
|
||||
res, err := httpClient.ABCIQuery("/key", key, true)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Error calling /abci_query: %v", err)
|
||||
}
|
||||
if !res.Code.IsOK() {
|
||||
return nil, errors.Errorf("Query got non-zero exit code: %v. %s", res.Code, res.Log)
|
||||
}
|
||||
return res.ResultQuery, nil
|
||||
}
|
||||
|
||||
// fetch the account by querying the app
|
||||
func getAccWithClient(httpClient *client.HTTP, address []byte) (*types.Account, error) {
|
||||
|
||||
key := types.AccountKey(address)
|
||||
response, err := queryWithClient(httpClient, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountBytes := response.Value
|
||||
|
||||
if len(accountBytes) == 0 {
|
||||
return nil, fmt.Errorf("Account bytes are empty for address: %X ", address) //never stack trace
|
||||
}
|
||||
|
||||
var acc *types.Account
|
||||
err = wire.ReadBinaryBytes(accountBytes, &acc)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Error reading account %X error: %v",
|
||||
accountBytes, err.Error())
|
||||
}
|
||||
|
||||
return acc, nil
|
||||
}
|
||||
|
||||
func getHeaderAndCommit(tmAddr string, height int) (*tmtypes.Header, *tmtypes.Commit, error) {
|
||||
httpClient := client.NewHTTP(tmAddr, "/websocket")
|
||||
res, err := httpClient.Commit(height)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Errorf("Error on commit: %v", err)
|
||||
}
|
||||
header := res.Header
|
||||
commit := res.Commit
|
||||
|
||||
return header, commit, nil
|
||||
}
|
||||
|
||||
func waitForBlock(httpClient *client.HTTP) error {
|
||||
res, err := httpClient.Status()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lastHeight := res.LatestBlockHeight
|
||||
for {
|
||||
res, err := httpClient.Status()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if res.LatestBlockHeight > lastHeight {
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -16,3 +16,14 @@ var VersionCmd = &cobra.Command{
|
||||
fmt.Println(version.Version)
|
||||
},
|
||||
}
|
||||
|
||||
// QuickVersionCmd - returns a version command based on version input
|
||||
func QuickVersionCmd(version string) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Show version info",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println(version)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user