Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanlott committed May 23, 2023
1 parent 0e145c9 commit c09306f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
run: go build -v ./...

- name: Test
run: go test -v -timeout=10s -race ./...
run: go test -v -timeout=10s ./...
30 changes: 18 additions & 12 deletions cmd/golem/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@ func main() {
Short: "an order matching engine in Go",
RunE: func(cmd *cobra.Command, args []string) error {
motd()

// create a context
ctx := context.Background()

// setup an accounts manager
accts := &accounts.InMemoryManager{}

// setup channels for wrapping our market
in := make(chan orderbook.Order)
out := make(chan *orderbook.Match)
status := make(chan []orderbook.Order)

// Run the book
go orderbook.Run(ctx, accts, in, out, status)

// start the server to bolt up to the engine
engine := server.NewServer(accts, in, out, status)

// run the server
return engine.Run()
},
}
Expand All @@ -46,16 +56,12 @@ func main() {

func motd() {
fmt.Printf(`
$$\
$$ |
$$$$$$\ $$$$$$\ $$ | $$$$$$\ $$$$$$\$$$$\
$$ __$$\ $$ __$$\ $$ |$$ __$$\ $$ _$$ _$$\
$$ / $$ |$$ / $$ |$$ |$$$$$$$$ |$$ / $$ / $$ |
$$ | $$ |$$ | $$ |$$ |$$ ____|$$ | $$ | $$ |
\$$$$$$$ |\$$$$$$ |$$ |\$$$$$$$\ $$ | $$ | $$ |
\____$$ | \______/ \__| \_______|\__| \__| \__|
$$\ $$ |
\$$$$$$ |
\______/
`)
===================================================
|| ██████ ██████ ██ ███████ ███ ███ ||
|| ██ ██ ██ ██ ██ ████ ████ ||
|| ██ ███ ██ ██ ██ █████ ██ ████ ██ ||
|| ██ ██ ██ ██ ██ ██ ██ ██ ██ ||
|| ██████ ██████ ███████ ███████ ██ ██ ||
===================================================
`)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ type OpWrite struct {
Result chan WriteResult
}

// FillResult contains the buy and sell order that were
// matched and filled. FillResult is only created after
// everything has been committed to state.
type FillResult struct {
Buy *Order

Check failure on line 26 in pkg/orderbook/attempt_fill/attempt_fill.go

View workflow job for this annotation

GitHub Actions / build

undefined: Order
Sell *Order

Check failure on line 27 in pkg/orderbook/attempt_fill/attempt_fill.go

View workflow job for this annotation

GitHub Actions / build

undefined: Order
Filled uint64
}

// WriteResult is returned as the result of an OpWrite.
type WriteResult struct {
Order Order

Check failure on line 33 in pkg/orderbook/attempt_fill/attempt_fill.go

View workflow job for this annotation

GitHub Actions / build

undefined: Order
Expand Down
9 changes: 0 additions & 9 deletions pkg/orderbook/orderbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ import (

var delay time.Duration = time.Second * 1

// FillResult contains the buy and sell order that were
// matched and filled. FillResult is only created after
// everything has been committed to state.
type FillResult struct {
Buy *Order
Sell *Order
Filled uint64
}

// Order is a struct for representing a simple order in the books.
type Order struct {
ID string
Expand Down

0 comments on commit c09306f

Please sign in to comment.