Add user store converter, improve config separation
This commit is contained in:
parent
e848117f4c
commit
f089822300
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -49,7 +49,7 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
if connStr == "" {
|
||||
connStr = config.DbConn
|
||||
connStr = config.DbConn()
|
||||
}
|
||||
if authConnStr == "" {
|
||||
authConnStr = connStr
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
2
go.mod
2
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
|
||||
|
4
go.sum
4
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=
|
||||
|
@ -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")
|
||||
)
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user