namereg rpc and tests

This commit is contained in:
Ethan Buchman
2015-05-30 01:19:02 -04:00
parent 8631d5085e
commit baaa69d7f8
9 changed files with 173 additions and 2 deletions
+17
View File
@@ -0,0 +1,17 @@
package core
import (
"fmt"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
)
// XXX: need we be careful about rendering bytes as string or is that their problem ?
func NameRegEntry(name []byte) (*ctypes.ResponseNameRegEntry, error) {
st := consensusState.GetState() // performs a copy
entry := st.GetNameRegEntry(name)
if entry == nil {
return nil, fmt.Errorf("Name %s not found", name)
}
return &ctypes.ResponseNameRegEntry{entry}, nil
}
+1
View File
@@ -20,6 +20,7 @@ var Routes = map[string]*rpc.RPCFunc{
"broadcast_tx": rpc.NewRPCFunc(BroadcastTx, []string{"tx"}),
"list_unconfirmed_txs": rpc.NewRPCFunc(ListUnconfirmedTxs, []string{}),
"list_accounts": rpc.NewRPCFunc(ListAccounts, []string{}),
"name_reg_entry": rpc.NewRPCFunc(NameRegEntry, []string{"name"}),
"unsafe/gen_priv_account": rpc.NewRPCFunc(GenPrivAccount, []string{}),
"unsafe/sign_tx": rpc.NewRPCFunc(SignTx, []string{"tx", "privAccounts"}),
}
+4
View File
@@ -100,3 +100,7 @@ type ResponseDumpConsensusState struct {
RoundState string `json:"round_state"`
PeerRoundStates []string `json:"peer_round_states"`
}
type ResponseNameRegEntry struct {
Entry *types.NameRegEntry `json:"entry"`
}