Gofmt, remove commented code

This commit is contained in:
lash 2025-01-21 15:43:26 +00:00
parent 2c8e60e1bb
commit 49335a290f
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
33 changed files with 181 additions and 191 deletions

View File

@ -10,7 +10,7 @@ type LangVar struct {
v []lang.Language
}
func(lv *LangVar) Set(s string) error {
func (lv *LangVar) Set(s string) error {
v, err := lang.LanguageFromCode(s)
if err != nil {
return err
@ -19,16 +19,14 @@ func(lv *LangVar) Set(s string) error {
return err
}
func(lv *LangVar) String() string {
func (lv *LangVar) String() string {
var s []string
for _, v := range(lv.v) {
for _, v := range lv.v {
s = append(s, v.Code)
}
return strings.Join(s, ",")
}
func(lv *LangVar) Langs() []lang.Language {
func (lv *LangVar) Langs() []lang.Language {
return lv.v
}

View File

@ -12,18 +12,18 @@ import (
"syscall"
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/logging"
"git.defalsify.org/vise.git/lang"
"git.defalsify.org/vise.git/logging"
"git.defalsify.org/vise.git/resource"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/visedriver/request"
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
)
var (
@ -118,7 +118,7 @@ func main() {
}
accountService := services.New(ctx, menuStorageService)
hl, err := lhs.GetHandler(accountService)
if err != nil {
fmt.Fprintf(os.Stderr, "httpaccountservice: %v\n", err)

View File

@ -14,12 +14,12 @@ import (
"git.defalsify.org/vise.git/logging"
"git.defalsify.org/vise.git/resource"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/visedriver/request"
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
"git.grassecon.net/grassrootseconomics/visedriver/request"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
)
var (

View File

@ -17,13 +17,13 @@ import (
"git.defalsify.org/vise.git/resource"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
httprequest "git.grassecon.net/grassrootseconomics/visedriver/request/http"
"git.grassecon.net/grassrootseconomics/visedriver/request"
httprequest "git.grassecon.net/grassrootseconomics/visedriver/request/http"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
)
var (
@ -116,7 +116,7 @@ func main() {
}
accountService := services.New(ctx, menuStorageService)
hl, err := lhs.GetHandler(accountService)
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())

View File

@ -10,14 +10,14 @@ import (
"syscall"
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/lang"
"git.defalsify.org/vise.git/logging"
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/lang"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
)
var (
@ -86,7 +86,7 @@ func main() {
fmt.Fprintf(os.Stderr, "menu storage service error: %v\n", err)
os.Exit(1)
}
if gettextDir != "" {
menuStorageService = menuStorageService.WithGettext(gettextDir, langs.Langs())
}

View File

@ -111,13 +111,13 @@ func main() {
signal.Notify(cterm, os.Interrupt, syscall.SIGTERM)
runner := &ssh.SshRunner{
Cfg: cfg,
Debug: engineDebug,
FlagFile: pfp,
Conn: conns,
SrvKeyFile: sshKeyFile,
Host: host,
Port: port,
Cfg: cfg,
Debug: engineDebug,
FlagFile: pfp,
Conn: conns,
SrvKeyFile: sshKeyFile,
Host: host,
Port: port,
}
go func() {
select {

View File

@ -5,10 +5,10 @@ import (
)
type Override struct {
DbConn *string
StateConn *string
DbConn *string
StateConn *string
ResourceConn *string
UserConn *string
UserConn *string
}
func NewOverride() *Override {
@ -17,10 +17,10 @@ func NewOverride() *Override {
var c string
var d string
o := &Override{
DbConn: &a,
StateConn: &b,
DbConn: &a,
StateConn: &b,
ResourceConn: &c,
UserConn: &d,
UserConn: &d,
}
return o
}

View File

@ -1,14 +1,14 @@
package config
import (
"git.grassecon.net/grassrootseconomics/visedriver/env"
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config"
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
"git.grassecon.net/grassrootseconomics/visedriver/env"
)
var (
GetConns = viseconfig.GetConns
EnvPath string
EnvPath string
)
func loadEnv() {
@ -20,10 +20,10 @@ func loadEnv() {
}
const (
defaultSSHHost string = "127.0.0.1"
defaultSSHPort uint = 7122
defaultSSHHost string = "127.0.0.1"
defaultSSHPort uint = 7122
defaultHTTPHost string = "127.0.0.1"
defaultHTTPPort uint = 7123
defaultHTTPPort uint = 7123
)
func LoadConfig() error {

View File

@ -1,11 +1,11 @@
package debug
import (
"fmt"
"encoding/binary"
"fmt"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
visedb "git.defalsify.org/vise.git/db"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
)
var (
@ -13,10 +13,10 @@ var (
)
type KeyInfo struct {
SessionId string
Typ uint8
SubTyp storedb.DataTyp
Label string
SessionId string
Typ uint8
SubTyp storedb.DataTyp
Label string
Description string
}
@ -53,12 +53,11 @@ func ToKeyInfo(k []byte, sessionId string) (KeyInfo, error) {
k = k[2:]
}
return o, nil
}
func subTypToString(v storedb.DataTyp) string {
return dbTypStr[v + visedb.DATATYPE_USERDATA + 1]
return dbTypStr[v+visedb.DATATYPE_USERDATA+1]
}
func typToString(v uint8) string {

View File

@ -1,3 +1,4 @@
//go:build debugdb
// +build debugdb
package debug
@ -11,37 +12,37 @@ import (
func init() {
DebugCap |= 1
dbTypStr[db.DATATYPE_STATE] = "internal state"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TRACKING_ID] = "tracking id"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_PUBLIC_KEY] = "public key"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACCOUNT_PIN] = "account pin"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_FIRST_NAME] = "first name"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_FAMILY_NAME] = "family name"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_YOB] = "year of birth"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_LOCATION] = "location"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_GENDER] = "gender"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_OFFERINGS] = "offerings"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_RECIPIENT] = "recipient"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_AMOUNT] = "amount"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TEMPORARY_VALUE] = "temporary value"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_SYM] = "active sym"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_BAL] = "active bal"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_BLOCKED_NUMBER] = "blocked number"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_PUBLIC_KEY_REVERSE] = "public_key_reverse"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_DECIMAL] = "active decimal"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_ADDRESS] = "active address"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_INCORRECT_PIN_ATTEMPTS] = "incorrect pin attempts"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_SELECTED_LANGUAGE_CODE] = "selected language"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_INITIAL_LANGUAGE_CODE] = "initial language"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_SYMBOLS] = "voucher symbols"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_BALANCES] = "voucher balances"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_DECIMALS] = "voucher decimals"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_ADDRESSES] = "voucher addresses"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_SENDERS] = "tx senders"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_RECIPIENTS] = "tx recipients"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_VALUES] = "tx values"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_ADDRESSES] = "tx addresses"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_HASHES] = "tx hashes"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_DATES] = "tx dates"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_SYMBOLS] = "tx symbols"
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_DECIMALS] = "tx decimals"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TRACKING_ID] = "tracking id"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_PUBLIC_KEY] = "public key"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACCOUNT_PIN] = "account pin"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_FIRST_NAME] = "first name"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_FAMILY_NAME] = "family name"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_YOB] = "year of birth"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_LOCATION] = "location"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_GENDER] = "gender"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_OFFERINGS] = "offerings"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_RECIPIENT] = "recipient"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_AMOUNT] = "amount"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TEMPORARY_VALUE] = "temporary value"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_SYM] = "active sym"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_BAL] = "active bal"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_BLOCKED_NUMBER] = "blocked number"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_PUBLIC_KEY_REVERSE] = "public_key_reverse"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_DECIMAL] = "active decimal"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_ADDRESS] = "active address"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_INCORRECT_PIN_ATTEMPTS] = "incorrect pin attempts"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_SELECTED_LANGUAGE_CODE] = "selected language"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_INITIAL_LANGUAGE_CODE] = "initial language"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_SYMBOLS] = "voucher symbols"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_BALANCES] = "voucher balances"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_DECIMALS] = "voucher decimals"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_ADDRESSES] = "voucher addresses"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_SENDERS] = "tx senders"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_RECIPIENTS] = "tx recipients"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_VALUES] = "tx values"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_ADDRESSES] = "tx addresses"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_HASHES] = "tx hashes"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_DATES] = "tx dates"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_SYMBOLS] = "tx symbols"
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_DECIMALS] = "tx decimals"
}

View File

@ -3,8 +3,8 @@ package debug
import (
"testing"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
visedb "git.defalsify.org/vise.git/db"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
)
func TestDebugDbSubKeyInfo(t *testing.T) {
@ -24,7 +24,7 @@ func TestDebugDbSubKeyInfo(t *testing.T) {
if r.SubTyp != 2 {
t.Fatalf("expected 2, got %d", r.SubTyp)
}
if DebugCap & 1 > 0 {
if DebugCap&1 > 0 {
if r.Label != "tracking id" {
t.Fatalf("expected 'tracking id', got '%s'", r.Label)
}
@ -45,7 +45,7 @@ func TestDebugDbKeyInfo(t *testing.T) {
if r.Typ != 16 {
t.Fatalf("expected 16, got %d", r.Typ)
}
if DebugCap & 1 > 0 {
if DebugCap&1 > 0 {
if r.Label != "internal state" {
t.Fatalf("expected 'internal_state', got '%s'", r.Label)
}
@ -68,7 +68,7 @@ func TestDebugDbKeyInfoRestore(t *testing.T) {
if r.Typ != 32 {
t.Fatalf("expected 32, got %d", r.Typ)
}
if DebugCap & 1 > 0 {
if DebugCap&1 > 0 {
if r.Label != "active sym" {
t.Fatalf("expected 'active sym', got '%s'", r.Label)
}

View File

@ -10,14 +10,14 @@ import (
"git.defalsify.org/vise.git/logging"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-vise/internal/cmd"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
"git.grassecon.net/grassrootseconomics/sarafu-vise/internal/cmd"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
)
var (
logg = logging.NewVanilla().WithContextKey("SessionId")
scriptDir = path.Join("services", "registration")
logg = logging.NewVanilla().WithContextKey("SessionId")
scriptDir = path.Join("services", "registration")
)
func main() {

View File

@ -8,18 +8,17 @@ import (
"path"
"strings"
"git.defalsify.org/vise.git/logging"
"git.defalsify.org/vise.git/lang"
"git.defalsify.org/vise.git/logging"
"git.grassecon.net/grassrootseconomics/visedriver/config"
)
const (
changeHeadSrc = `LOAD reset_account_authorized 0
LOAD reset_incorrect 0
CATCH incorrect_pin flag_incorrect_pin 1
CATCH pin_entry flag_account_authorized 0
`
`
selectSrc = `LOAD set_language 6
RELOAD set_language
@ -29,8 +28,8 @@ MOVE language_changed
)
var (
logg = logging.NewVanilla()
mouts string
logg = logging.NewVanilla()
mouts string
incmps string
)
@ -63,7 +62,7 @@ func main() {
}
logg.Tracef("using languages", "lang", config.Languages)
for i, v := range(config.Languages) {
for i, v := range config.Languages {
ln, err := lang.LanguageFromCode(v)
if err != nil {
fmt.Fprintf(os.Stderr, "error parsing language: %s\n", v)
@ -76,7 +75,7 @@ func main() {
incmps += fmt.Sprintf("INCMP %s %v\n", v, n)
p := path.Join(srcDir, v)
w, err := os.OpenFile(p, os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
w, err := os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
if err != nil {
fmt.Fprintf(os.Stderr, "failed open language set template output: %v\n", err)
os.Exit(1)
@ -93,7 +92,7 @@ func main() {
src += "INCMP . *\n"
p := path.Join(srcDir, "select_language.vis")
w, err := os.OpenFile(p, os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
w, err := os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
if err != nil {
fmt.Fprintf(os.Stderr, "failed open select language vis output: %v\n", err)
os.Exit(1)
@ -107,7 +106,7 @@ func main() {
src = changeHeadSrc + src
p = path.Join(srcDir, "change_language.vis")
w, err = os.OpenFile(p, os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
w, err = os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
if err != nil {
fmt.Fprintf(os.Stderr, "failed open select language vis output: %v\n", err)
os.Exit(1)

View File

@ -7,11 +7,11 @@ import (
"os"
"path"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-vise/debug"
"git.defalsify.org/vise.git/db"
"git.defalsify.org/vise.git/logging"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/sarafu-vise/debug"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
)
var (

View File

@ -273,7 +273,7 @@ func (h *MenuHandlers) CheckBlockedStatus(ctx context.Context, sym string, input
}
pinAttemptsValue, _ := strconv.ParseUint(string(currentWrongPinAttempts), 0, 64)
if pinAttemptsValue == 0 {
res.FlagReset = append(res.FlagReset, flag_account_blocked)
return res, nil

View File

@ -35,13 +35,6 @@ func (eu *EventsUpdater) HandleCustodialRegistration(ctx context.Context, ev *ap
if err != nil {
return err
}
// err = pe.Load(identity.SessionId)
// if err != nil {
// return err
// }
// st := pe.GetState()
// st.SetFlag(accountCreatedFlag)
// return pe.Save(identity.SessionId)
logg.DebugCtxf(ctx, "received custodial registration event", "identity", identity)
return nil
}

View File

@ -4,12 +4,12 @@ import (
"context"
"fmt"
"git.defalsify.org/vise.git/persist"
"git.defalsify.org/vise.git/logging"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
"git.defalsify.org/vise.git/persist"
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
)
var (
@ -17,9 +17,9 @@ var (
)
type EventsUpdater struct {
api remote.AccountService
api remote.AccountService
formatFunc func(string, int, any) string
store storage.StorageService
store storage.StorageService
}
func NewEventsUpdater(api remote.AccountService, store storage.StorageService) *EventsUpdater {

View File

@ -6,13 +6,13 @@ import (
"strings"
"git.defalsify.org/vise.git/db"
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
"git.grassecon.net/grassrootseconomics/common/identity"
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
)
// execute all
// execute all
func (eu *EventsUpdater) updateToken(ctx context.Context, identity identity.Identity, userStore *store.UserDataStore, tokenAddress string) error {
err := eu.updateTokenList(ctx, identity, userStore)
if err != nil {
@ -47,7 +47,6 @@ func (eu *EventsUpdater) updateToken(ctx context.Context, identity identity.Iden
return nil
}
// set default token to given symbol.
func (eu *EventsUpdater) updateDefaultToken(ctx context.Context, identity identity.Identity, userStore *store.UserDataStore, activeSym string) error {
pfxDb := toPrefixDb(userStore, identity.SessionId)
@ -59,7 +58,6 @@ func (eu *EventsUpdater) updateDefaultToken(ctx context.Context, identity identi
return store.UpdateVoucherData(ctx, userStore, identity.SessionId, tokenData)
}
// handle token transfer.
//
// if from and to are NOT the same, handle code will be executed once for each side of the transfer.
@ -189,7 +187,7 @@ func (eu *EventsUpdater) updateTokenTransferList(ctx context.Context, identity i
return err
}
for i, tx := range(txs) {
for i, tx := range txs {
r = append(r, eu.formatFunc(apievent.EventTokenTransferTag, i, tx))
}

View File

@ -5,8 +5,8 @@ import (
"fmt"
"git.defalsify.org/vise.git/logging"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
)
var (
@ -14,17 +14,17 @@ var (
)
type Cmd struct {
sessionId string
conn storage.ConnData
sessionId string
conn storage.ConnData
flagParser *application.FlagManager
cmd int
enable bool
exec func(ctx context.Context, ss storage.StorageService) error
cmd int
enable bool
exec func(ctx context.Context, ss storage.StorageService) error
}
func NewCmd(sessionId string, flagParser *application.FlagManager) *Cmd {
return &Cmd{
sessionId: sessionId,
sessionId: sessionId,
flagParser: flagParser,
}
}
@ -94,5 +94,3 @@ func (c *Cmd) Parse(args []string) error {
return fmt.Errorf("unknown subcommand: %s", cmd)
}

View File

@ -9,14 +9,14 @@ import (
"regexp"
"testing"
"github.com/gofrs/uuid"
"git.defalsify.org/vise.git/logging"
"git.grassecon.net/grassrootseconomics/visedriver/testutil/driver"
"git.grassecon.net/grassrootseconomics/sarafu-vise/testutil"
"git.grassecon.net/grassrootseconomics/visedriver/testutil/driver"
"github.com/gofrs/uuid"
)
var (
logg = logging.NewVanilla().WithDomain("menutraversaltest")
logg = logging.NewVanilla().WithDomain("menutraversaltest")
testData = driver.ReadData()
sessionID string
src = rand.NewSource(42)

View File

@ -12,7 +12,7 @@ func (p *Profile) InsertOrShift(index int, value string) {
for len(p.ProfileItems) < index {
p.ProfileItems = append(p.ProfileItems, "0")
}
p.ProfileItems = append(p.ProfileItems, "0")
p.ProfileItems = append(p.ProfileItems, "0")
p.ProfileItems[index] = value
}
}

View File

@ -1,16 +1,17 @@
//go:build !online
// +build !online
package services
import (
"fmt"
"context"
"fmt"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
)
type localEmitter struct {

View File

@ -1,3 +1,4 @@
//go:build online
// +build online
package services
@ -5,9 +6,9 @@ package services
import (
"context"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
)
func New(ctx context.Context, storageService storage.StorageService, conn storage.ConnData) remote.AccountService {

View File

@ -29,7 +29,7 @@ func NewSshKeyStore(ctx context.Context, dbDir string) (*SshKeyStore, error) {
return keyStore, nil
}
func(s *SshKeyStore) AddFromFile(ctx context.Context, fp string, sessionId string) error {
func (s *SshKeyStore) AddFromFile(ctx context.Context, fp string, sessionId string) error {
_, err := os.Stat(fp)
if err != nil {
return fmt.Errorf("cannot open ssh server public key file: %v\n", err)
@ -51,7 +51,7 @@ func(s *SshKeyStore) AddFromFile(ctx context.Context, fp string, sessionId strin
return s.store.Put(ctx, k, []byte(sessionId))
}
func(s *SshKeyStore) Get(ctx context.Context, pubKey ssh.PublicKey) (string, error) {
func (s *SshKeyStore) Get(ctx context.Context, pubKey ssh.PublicKey) (string, error) {
s.store.SetLanguage(nil)
s.store.SetSession("")
s.store.SetPrefix(storage.DATATYPE_EXTEND)
@ -63,6 +63,6 @@ func(s *SshKeyStore) Get(ctx context.Context, pubKey ssh.PublicKey) (string, err
return string(v), nil
}
func(s *SshKeyStore) Close(ctx context.Context) error {
func (s *SshKeyStore) Close(ctx context.Context) error {
return s.store.Close(ctx)
}

View File

@ -2,8 +2,8 @@ package ssh
import (
"context"
"encoding/hex"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"net"
@ -16,9 +16,9 @@ import (
"git.defalsify.org/vise.git/logging"
"git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
)
var (
@ -26,32 +26,32 @@ var (
)
type auther struct {
Ctx context.Context
Ctx context.Context
keyStore *SshKeyStore
auth map[string]string
auth map[string]string
}
func NewAuther(ctx context.Context, keyStore *SshKeyStore) *auther {
return &auther{
Ctx: ctx,
Ctx: ctx,
keyStore: keyStore,
auth: make(map[string]string),
auth: make(map[string]string),
}
}
func(a *auther) Check(conn ssh.ConnMetadata, pubKey ssh.PublicKey) (*ssh.Permissions, error) {
func (a *auther) Check(conn ssh.ConnMetadata, pubKey ssh.PublicKey) (*ssh.Permissions, error) {
logg.TraceCtxf(a.Ctx, "looking for publickey", "pubkey", fmt.Sprintf("%x", pubKey))
va, err := a.keyStore.Get(a.Ctx, pubKey)
if err != nil {
return nil, err
}
ka := hex.EncodeToString(conn.SessionID())
a.auth[ka] = va
a.auth[ka] = va
fmt.Fprintf(os.Stderr, "connect: %s -> %s\n", ka, va)
return nil, nil
}
func(a *auther) FromConn(c *ssh.ServerConn) (string, error) {
func (a *auther) FromConn(c *ssh.ServerConn) (string, error) {
if c == nil {
return "", errors.New("nil server conn")
}
@ -61,8 +61,7 @@ func(a *auther) FromConn(c *ssh.ServerConn) (string, error) {
return a.Get(c.Conn.SessionID())
}
func(a *auther) Get(k []byte) (string, error) {
func (a *auther) Get(k []byte) (string, error) {
ka := hex.EncodeToString(k)
v, ok := a.auth[ka]
if !ok {
@ -72,19 +71,19 @@ func(a *auther) Get(k []byte) (string, error) {
}
type SshRunner struct {
Ctx context.Context
Cfg engine.Config
FlagFile string
Conn storage.Conns
Debug bool
Ctx context.Context
Cfg engine.Config
FlagFile string
Conn storage.Conns
Debug bool
SrvKeyFile string
Host string
Port uint
wg sync.WaitGroup
lst net.Listener
Host string
Port uint
wg sync.WaitGroup
lst net.Listener
}
func(s *SshRunner) serve(ctx context.Context, sessionId string, ch ssh.NewChannel, en engine.Engine) error {
func (s *SshRunner) serve(ctx context.Context, sessionId string, ch ssh.NewChannel, en engine.Engine) error {
if ch == nil {
return errors.New("nil channel")
}
@ -101,7 +100,7 @@ func(s *SshRunner) serve(ctx context.Context, sessionId string, ch ssh.NewChanne
go func(reqIn <-chan *ssh.Request) {
defer s.wg.Done()
for req := range reqIn {
req.Reply(req.Type == "shell", nil)
req.Reply(req.Type == "shell", nil)
}
_ = requests
}(requests)
@ -141,11 +140,11 @@ func(s *SshRunner) serve(ctx context.Context, sessionId string, ch ssh.NewChanne
return nil
}
func(s *SshRunner) Stop() error {
func (s *SshRunner) Stop() error {
return s.lst.Close()
}
func(s *SshRunner) GetEngine(sessionId string) (engine.Engine, func(), error) {
func (s *SshRunner) GetEngine(sessionId string) (engine.Engine, func(), error) {
ctx := s.Ctx
menuStorageService := storage.NewMenuStorageService(s.Conn)
@ -202,7 +201,7 @@ func(s *SshRunner) GetEngine(sessionId string) (engine.Engine, func(), error) {
}
// adapted example from crypto/ssh package, NewServerConn doc
func(s *SshRunner) Run(ctx context.Context, keyStore *SshKeyStore) {
func (s *SshRunner) Run(ctx context.Context, keyStore *SshKeyStore) {
s.Ctx = ctx
running := true
@ -255,7 +254,7 @@ func(s *SshRunner) Run(ctx context.Context, keyStore *SshKeyStore) {
ssh.DiscardRequests(rC)
s.wg.Done()
}()
sessionId, err := auth.FromConn(srvConn)
if err != nil {
logg.ErrorCtxf(ctx, "Cannot find authentication")

View File

@ -3,8 +3,8 @@ package store
import (
"testing"
"github.com/alecthomas/assert/v2"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
"github.com/alecthomas/assert/v2"
)
func TestParseAndScaleAmount(t *testing.T) {

View File

@ -4,10 +4,10 @@ import (
"context"
visedb "git.defalsify.org/vise.git/db"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
"git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
"git.grassecon.net/grassrootseconomics/common/hex"
"git.grassecon.net/grassrootseconomics/common/identity"
"git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
)
// TODO: Rename interface, "datastore" is redundant naming and too general

View File

@ -9,24 +9,24 @@ import (
"path/filepath"
"time"
"github.com/jackc/pgx/v5/pgxpool"
"git.defalsify.org/vise.git/engine"
"git.defalsify.org/vise.git/resource"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"git.grassecon.net/grassrootseconomics/sarafu-api/testutil/testservice"
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
"git.grassecon.net/grassrootseconomics/sarafu-api/testutil/testservice"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
"git.grassecon.net/grassrootseconomics/sarafu-vise/testutil/testtag"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
"github.com/jackc/pgx/v5/pgxpool"
)
// CleanDatabase removes all test data from the database
func CleanDatabase() {
for _, v := range([]int8{
for _, v := range []int8{
storage.STORETYPE_STATE,
storage.STORETYPE_USER,
}) {
} {
conn := conns[v]
logg.Infof("cleaning test database", "typ", v, "db", conn)
if conn.DbType() == storage.DBTYPE_POSTGRES {

View File

@ -1,10 +1,10 @@
//go:build testfsdb
// +build testfsdb
package testutil
import (
"os"
)
const (

View File

@ -1,10 +1,11 @@
//go:build testgdbmdb
// +build testgdbmdb
package testutil
import (
"os"
"net/url"
"os"
)
const (

View File

@ -4,21 +4,21 @@ import (
"context"
"path"
testdataloader "github.com/peteole/testdata-loader"
"git.defalsify.org/vise.git/logging"
fsdb "git.defalsify.org/vise.git/db/fs"
"git.defalsify.org/vise.git/db"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
fsdb "git.defalsify.org/vise.git/db/fs"
"git.defalsify.org/vise.git/logging"
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
testdataloader "github.com/peteole/testdata-loader"
)
var (
logg = logging.NewVanilla().WithDomain("sarafu-vise.testutil").WithContextKey("SessionId")
conns storage.Conns
logg = logging.NewVanilla().WithDomain("sarafu-vise.testutil").WithContextKey("SessionId")
conns storage.Conns
resourceDb db.Db
baseDir = testdataloader.GetBasePath()
scriptDir = path.Join(baseDir, "services", "registration")
override config.Override
baseDir = testdataloader.GetBasePath()
scriptDir = path.Join(baseDir, "services", "registration")
override config.Override
)
func init() {

View File

@ -1,3 +1,4 @@
//go:build !online
// +build !online
package testtag

View File

@ -1,3 +1,4 @@
//go:build online
// +build online
package testtag