diff --git a/cmd/africastalking/main.go b/cmd/africastalking/main.go index 2fd76de..3e4420c 100644 --- a/cmd/africastalking/main.go +++ b/cmd/africastalking/main.go @@ -60,9 +60,9 @@ func main() { flag.Parse() if connStr == "" { - connStr = config.DbConn + connStr = config.DbConn() } - connData, err := storage.ToConnData(config.DbConn) + connData, err := storage.ToConnData(connStr) if err != nil { fmt.Fprintf(os.Stderr, "connstr err: %v", err) os.Exit(1) @@ -72,7 +72,7 @@ func main() { ctx := context.Background() ctx = context.WithValue(ctx, "Database", database) - ln, err := lang.LanguageFromCode(config.DefaultLanguage) + ln, err := lang.LanguageFromCode(config.Language()) if err != nil { fmt.Fprintf(os.Stderr, "default language set error: %v", err) os.Exit(1) diff --git a/cmd/async/main.go b/cmd/async/main.go index 891bd33..3fba1fe 100644 --- a/cmd/async/main.go +++ b/cmd/async/main.go @@ -68,7 +68,7 @@ func main() { flag.Parse() if connStr == "" { - connStr = config.DbConn + connStr = config.DbConn() } connData, err := storage.ToConnData(connStr) if err != nil { @@ -80,7 +80,7 @@ func main() { ctx := context.Background() - ln, err := lang.LanguageFromCode(config.DefaultLanguage) + ln, err := lang.LanguageFromCode(config.Language()) if err != nil { fmt.Fprintf(os.Stderr, "default language set error: %v", err) os.Exit(1) diff --git a/cmd/http/main.go b/cmd/http/main.go index eb091ba..a8ea564 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -56,7 +56,7 @@ func main() { flag.Parse() if connStr == "" { - connStr = config.DbConn + connStr = config.DbConn() } connData, err := storage.ToConnData(connStr) if err != nil { @@ -68,7 +68,7 @@ func main() { ctx := context.Background() - ln, err := lang.LanguageFromCode(config.DefaultLanguage) + ln, err := lang.LanguageFromCode(config.Language()) if err != nil { fmt.Fprintf(os.Stderr, "default language set error: %v", err) os.Exit(1) diff --git a/cmd/main.go b/cmd/main.go index 240cb8d..493090a 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -32,7 +32,6 @@ func main() { var connStr string var size uint var sessionId string - var database string var engineDebug bool var resourceDir string var err error @@ -49,7 +48,7 @@ func main() { flag.Parse() if connStr != "" { - connStr = config.DbConn + connStr = config.DbConn() } connData, err := storage.ToConnData(connStr) if err != nil { @@ -60,14 +59,13 @@ func main() { logg.Infof("start command", "conn", connData, "outputsize", size) if len(langs.Langs()) == 0 { - langs.Set(config.DefaultLanguage) + langs.Set(config.Language()) } ctx := context.Background() ctx = context.WithValue(ctx, "SessionId", sessionId) - ctx = context.WithValue(ctx, "Database", database) - ln, err := lang.LanguageFromCode(config.DefaultLanguage) + ln, err := lang.LanguageFromCode(config.Language()) if err != nil { fmt.Fprintf(os.Stderr, "default language set error: %v", err) os.Exit(1) diff --git a/cmd/ssh/main.go b/cmd/ssh/main.go index 03fa024..8397be8 100644 --- a/cmd/ssh/main.go +++ b/cmd/ssh/main.go @@ -49,7 +49,7 @@ func main() { flag.Parse() if connStr == "" { - connStr = config.DbConn + connStr = config.DbConn() } if authConnStr == "" { authConnStr = connStr diff --git a/config/config.go b/config/config.go index 03f8e24..3df8afc 100644 --- a/config/config.go +++ b/config/config.go @@ -15,11 +15,6 @@ const ( defaultSSHPort uint = 7122 ) -var ( - DbConn = viseconfig.DbConn - DefaultLanguage = viseconfig.DefaultLanguage -) - func LoadConfig() error { err := viseconfig.LoadConfig() if err != nil { @@ -29,11 +24,17 @@ func LoadConfig() error { if err != nil { return err } - DbConn = viseconfig.DbConn - DefaultLanguage = viseconfig.DefaultLanguage return nil } +func DbConn() string { + return viseconfig.DbConn +} + +func Language() string { + return viseconfig.DefaultLanguage +} + func Host() string { return apiconfig.Host() } diff --git a/devtools/store/dump/main.go b/devtools/store/dump/main.go index ee66e21..d896da8 100644 --- a/devtools/store/dump/main.go +++ b/devtools/store/dump/main.go @@ -43,9 +43,9 @@ func main() { flag.Parse() if connStr != "" { - connStr = config.DbConn + connStr = config.DbConn() } - connData, err := storage.ToConnData(config.DbConn) + connData, err := storage.ToConnData(connStr) if err != nil { fmt.Fprintf(os.Stderr, "connstr err: %v", err) os.Exit(1) diff --git a/devtools/store/generate/main.go b/devtools/store/generate/main.go index 491beca..bfcc483 100644 --- a/devtools/store/generate/main.go +++ b/devtools/store/generate/main.go @@ -37,9 +37,9 @@ func main() { flag.Parse() if connStr != "" { - connStr = config.DbConn + connStr = config.DbConn() } - connData, err := storage.ToConnData(config.DbConn) + connData, err := storage.ToConnData(connStr) if err != nil { fmt.Fprintf(os.Stderr, "connstr err: %v", err) os.Exit(1) diff --git a/go.mod b/go.mod index 12c10b2..5cedcbb 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d git.grassecon.net/grassrootseconomics/common v0.0.0-20250112102149-4feac5e490e9 git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250112110836-26a51bc95f38 - git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250112104023-611c5a8dfc80 + git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250112121325-9e4c65c8b4d1 git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250112104256-7d37d7f5cac5 github.com/alecthomas/assert/v2 v2.2.2 github.com/gofrs/uuid v4.4.0+incompatible diff --git a/go.sum b/go.sum index e425403..ca35ba3 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ git.grassecon.net/grassrootseconomics/common v0.0.0-20250112102149-4feac5e490e9 git.grassecon.net/grassrootseconomics/common v0.0.0-20250112102149-4feac5e490e9/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250112110836-26a51bc95f38 h1:M++O6THA26LRdC7jfsPCaIIPMosNhFc+PgnEtDY3+hk= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250112110836-26a51bc95f38/go.mod h1:E0ayNSbqpt+aAHoA7f7jXZcH2Zgjkt7rYs50YH9sLgk= -git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250112104023-611c5a8dfc80 h1:8j7iDSC9lzOM8NexEQlMfEn+3mJStDf66OTZK8ulsho= -git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250112104023-611c5a8dfc80/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U= +git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250112121325-9e4c65c8b4d1 h1:RfU5/WFfPxDptlkyx4MT+4YmO79sY6HvIngUq5uwQPU= +git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250112121325-9e4c65c8b4d1/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U= git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250112104256-7d37d7f5cac5 h1:byD+vsY9kqCVFX2Kx2+Z3/Lqk10l4MQnUBXm/zLpy20= git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250112104256-7d37d7f5cac5/go.mod h1:wf5CtGf07LRtnPqr9sefMY+bQK5oASsvzIr7ebs7MWU= github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk= diff --git a/store/db/db.go b/store/db/db.go index 91341d3..b70cc5e 100644 --- a/store/db/db.go +++ b/store/db/db.go @@ -74,6 +74,7 @@ const ( ) const ( + // List of senders for valid transactions in the user context. DATA_TX_SENDERS = 512 + iota // List of recipients for valid transactions in the user context. DATA_TX_RECIPIENTS @@ -91,6 +92,11 @@ const ( DATA_TX_DECIMALS ) +const ( + // Token transfer list + DATA_TRANSACTIONS = 1024 + iota +) + var ( logg = logging.NewVanilla().WithDomain("urdt-common") ) diff --git a/store/user_store.go b/store/user_store.go index 8b358e4..920d32e 100644 --- a/store/user_store.go +++ b/store/user_store.go @@ -35,3 +35,7 @@ func (store *UserDataStore) WriteEntry(ctx context.Context, sessionId string, ty k := storedb.ToBytes(typ) return store.Put(ctx, k, value) } + +func StoreToPrefixDb(userStore *UserDataStore, pfx []byte) storedb.PrefixDb { + return storedb.NewSubPrefixDb(userStore.Db, pfx) +}