Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Commit

Permalink
Updated path of library
Browse files Browse the repository at this point in the history
  • Loading branch information
hinoshiba committed Jan 3, 2021
1 parent 1410eaf commit e8b4d54
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 30 deletions.
30 changes: 15 additions & 15 deletions src/go/src/miniquet2/exec/miniquet2/miniquet2.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ import (
)

import (
"github.com/hinoshiba/go-gmo-coin/gomocoin"
"github.com/vouquet/go-gmo-coin/gomocoin"
"github.com/BurntSushi/toml"
"github.com/vouquet/brain"
)

import (
"miniquet2/miniquet"
)

const (
MiniketName string = "miniquet2 v0.0.1.a51d578d5d291efb5af45a32a158fe6c4560146b"
MiniketName string = "miniquet2 v0.0.1"
)

var (
Expand All @@ -30,9 +35,9 @@ var (
type Miniket2 struct {
m *Model

trs map[string]*Trader
trs map[string]*miniquet.Trader
shop *gomocoin.GoMOcoin
st *Storage
st *miniquet.Storage
}

func NewMiniket2(api string, secret string, s_path string) (*Miniket2, error) {
Expand All @@ -46,14 +51,14 @@ func NewMiniket2(api string, secret string, s_path string) (*Miniket2, error) {
return nil, err
}

storage, err := OpenStorage(s_path, nil)
storage, err := miniquet.OpenStorage(s_path, nil)
if err != nil {
return nil, err
}

self := &Miniket2{
m:m,
trs: make(map[string]*Trader),
trs: make(map[string]*miniquet.Trader),
shop: gmocoin,
st: storage,
}
Expand Down Expand Up @@ -145,12 +150,12 @@ func (self *Miniket2) loadStorage() error {
}

func (self *Miniket2) buildTrader() error {
a_tr := NewTrader("alice", "Trade with a difference of 0.2 point.", self.shop, self.st)
a_tr.SetCheckFunc(alice)
a_tr := miniquet.NewTrader("alice", "Trade with a difference of 0.2 point.", self.shop, self.st)
a_tr.SetCheckFunc(brain.Alice)
self.trs["alice"] = a_tr

j_tr := NewTrader("john", "Trade with a difference of 1 point.", self.shop, self.st)
j_tr.SetCheckFunc(john)
j_tr := miniquet.NewTrader("john", "Trade with a difference of 1 point.", self.shop, self.st)
j_tr.SetCheckFunc(brain.John)
self.trs["john"] = j_tr

for _, tr := range self.trs {
Expand Down Expand Up @@ -233,11 +238,6 @@ func (self *Miniket2) buildCommand() error {
return nil
}

type Logger interface {
WriteMsgLog(string, ...interface{})
WriteErrLog(string, ...interface{})
}

func die(s string, msg ...interface{}) {
fmt.Fprintf(os.Stderr, s + "\n" , msg...)
os.Exit(1)
Expand Down
10 changes: 7 additions & 3 deletions src/go/src/miniquet2/exec/miniquet2/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import (

import (
"github.com/nsf/termbox-go"
"github.com/hinoshiba/go-gmo-coin/gomocoin"
"github.com/vouquet/go-gmo-coin/gomocoin"
)

import (
"miniquet2/miniquet"
)

type Message struct {
Expand Down Expand Up @@ -260,11 +264,11 @@ func (self *Model) run_operator(com_ch chan string) {
}
}

func (self *Model) AddTrader(tr *Trader) error {
func (self *Model) AddTrader(tr *miniquet.Trader) error {
return self.m_pg.Add(tr)
}

func (self *Model) RemoveTrader(tr *Trader) error {
func (self *Model) RemoveTrader(tr *miniquet.Trader) error {
return self.m_pg.Remove(tr)
}

Expand Down
18 changes: 11 additions & 7 deletions src/go/src/miniquet2/exec/miniquet2/model_progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ import (
"sync"
)

import (
"miniquet2/miniquet"
)

type ProgressModel struct {
view_handler func(map[string]*Trader)
traders map[string]*Trader
view_handler func(map[string]*miniquet.Trader)
traders map[string]*miniquet.Trader

mtx *sync.Mutex
}

func NewProgressModel() *ProgressModel {
return &ProgressModel{
traders:make(map[string]*Trader, 0),
traders:make(map[string]*miniquet.Trader, 0),
mtx:new(sync.Mutex),
}
}

func (self *ProgressModel) ViewHandler(f func(map[string]*Trader)) {
func (self *ProgressModel) ViewHandler(f func(map[string]*miniquet.Trader)) {
self.mtx.Lock()
defer self.mtx.Unlock()

Expand All @@ -33,7 +37,7 @@ func (self *ProgressModel) Publish() {
self.publish()
}

func (self *ProgressModel) call_view_handler(ts map[string]*Trader) {
func (self *ProgressModel) call_view_handler(ts map[string]*miniquet.Trader) {
if self.view_handler == nil {
return
}
Expand All @@ -44,7 +48,7 @@ func (self *ProgressModel) publish() {
self.call_view_handler(self.traders)
}

func (self *ProgressModel) Add(n_tr *Trader) error {
func (self *ProgressModel) Add(n_tr *miniquet.Trader) error {
self.mtx.Lock()
defer self.mtx.Unlock()

Expand All @@ -57,7 +61,7 @@ func (self *ProgressModel) Add(n_tr *Trader) error {
return nil
}

func (self *ProgressModel) Remove(r_tr *Trader) error {
func (self *ProgressModel) Remove(r_tr *miniquet.Trader) error {
self.mtx.Lock()
defer self.mtx.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion src/go/src/miniquet2/exec/miniquet2/model_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

import (
"github.com/hinoshiba/go-gmo-coin/gomocoin"
"github.com/vouquet/go-gmo-coin/gomocoin"
)

type StatusModel struct {
Expand Down
6 changes: 5 additions & 1 deletion src/go/src/miniquet2/exec/miniquet2/view_progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"github.com/nsf/termbox-go"
)

import (
"miniquet2/miniquet"
)

type ProgressViewLayer struct {
ViewLayerBase
}
Expand All @@ -20,7 +24,7 @@ func NewProgressViewLayer(strach_factor int) *ProgressViewLayer {
}
}

func (self *ProgressViewLayer) SetValues(trs map[string]*Trader) {
func (self *ProgressViewLayer) SetValues(trs map[string]*miniquet.Trader) {
self.mtx.Lock()
defer self.mtx.Unlock()
defer self.call_flusher()
Expand Down
6 changes: 6 additions & 0 deletions src/go/src/miniquet2/miniquet/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package miniquet

type Logger interface {
WriteMsgLog(string, ...interface{})
WriteErrLog(string, ...interface{})
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package miniquet

import (
"io"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package miniquet

import (
"fmt"
Expand All @@ -9,7 +9,7 @@ import (

import (
"github.com/google/uuid"
"github.com/hinoshiba/go-gmo-coin/gomocoin"
"github.com/vouquet/go-gmo-coin/gomocoin"
)

type Trader struct {//TODO: Upgrade2interface
Expand Down

0 comments on commit e8b4d54

Please sign in to comment.