You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
762 B

10 years ago
10 years ago
10 years ago
10 years ago
  1. package core
  2. import (
  3. "fmt"
  4. ctypes "github.com/tendermint/tendermint/rpc/core/types"
  5. "github.com/tendermint/tendermint/types"
  6. )
  7. func GetName(name string) (*types.NameRegEntry, error) {
  8. st := consensusState.GetState() // performs a copy
  9. entry := st.GetNameRegEntry(name)
  10. if entry == nil {
  11. return nil, fmt.Errorf("Name %s not found", name)
  12. }
  13. return entry, nil
  14. }
  15. func ListNames() (*ctypes.ResponseListNames, error) {
  16. var blockHeight int
  17. var names []*types.NameRegEntry
  18. state := consensusState.GetState()
  19. blockHeight = state.LastBlockHeight
  20. state.GetNames().Iterate(func(key interface{}, value interface{}) bool {
  21. names = append(names, value.(*types.NameRegEntry))
  22. return false
  23. })
  24. return &ctypes.ResponseListNames{blockHeight, names}, nil
  25. }