[golang] implement automation loop and add contract accepting
This commit is contained in:
parent
3dad3f60f2
commit
d97985a694
9 changed files with 223 additions and 64 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"database/sql"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func initDB(ctx context.Context, url string) (*sql.DB, error) {
|
||||
|
@ -90,6 +91,21 @@ func (db *DB) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (db *DB) Reset() error {
|
||||
_, err := db.Exec(strings.Join([]string{
|
||||
"DELETE FROM agents;",
|
||||
"DELETE FROM markets;",
|
||||
"DELETE FROM systems;",
|
||||
"DELETE FROM tokens;",
|
||||
"DELETE FROM transactions;",
|
||||
"DELETE FROM waypoints;",
|
||||
}, ""))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to reset database: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *DB) Exec(query string, args ...any) (sql.Result, error) {
|
||||
return db.writeDB.ExecContext(db.ctx, query, args...)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue