MCPcopy Create free account
hub / github.com/DEROFDN/Engram / GetAccounts

Function GetAccounts

res.go:57–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57func GetAccounts() (result []string, err error) {
58 path := ""
59
60 switch session.Network {
61 case NETWORK_MAINNET:
62 _, err = os.Stat(filepath.Join(AppPath(), "mainnet"))
63 if err != nil {
64 return
65 } else {
66 path = filepath.Join(AppPath(), "mainnet") + string(filepath.Separator)
67 }
68 case NETWORK_SIMULATOR:
69 _, err = os.Stat(filepath.Join(AppPath(), "testnet_simulator"))
70 if err != nil {
71 return
72 } else {
73 path = filepath.Join(AppPath(), "testnet_simulator") + string(filepath.Separator)
74 }
75 default:
76 _, err = os.Stat(filepath.Join(AppPath(), "testnet"))
77 if err != nil {
78 return
79 } else {
80 path = filepath.Join(AppPath(), "testnet") + string(filepath.Separator)
81 }
82 }
83
84 matches, _ := filepath.Glob(path + "*.db")
85 result = []string{}
86
87 for _, match := range matches {
88 check, _ := os.Stat(match)
89 if !check.IsDir() {
90 if strings.Contains(match, ".db") {
91 split := strings.Split(match, string(filepath.Separator))
92 pos := len(split) - 1
93 match = split[pos]
94 result = append(result, match)
95 }
96 }
97 }
98
99 /*
100 if len(result) == 0 {
101 // TODO: May do something here like start the user at Create/Restore Account window.
102 }
103 */
104
105 return
106}
107
108func findAccount() (result bool) {
109 matches, err := filepath.Glob(session.Path)

Callers 1

layoutMainFunction · 0.85

Calls 1

AppPathFunction · 0.85

Tested by

no test coverage detected