Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
process
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
process
Commits
db3fa0df
Commit
db3fa0df
authored
Mar 11, 2025
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update engine init
parent
8e04c110
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
engine.go
engine/engine.go
+8
-2
No files found.
engine/engine.go
View file @
db3fa0df
package
engine
package
engine
import
(
import
(
"fmt"
"sync"
"sync"
"github.com/exchain/process/database"
"github.com/exchain/process/database"
...
@@ -8,6 +9,7 @@ import (
...
@@ -8,6 +9,7 @@ import (
"github.com/exchain/process/orderbook"
"github.com/exchain/process/orderbook"
"github.com/exchain/process/types"
"github.com/exchain/process/types"
"github.com/ethereum/go-ethereum/log"
"github.com/exchain/go-exchain/exchain"
"github.com/exchain/go-exchain/exchain"
"github.com/exchain/go-exchain/exchain/chaindb"
"github.com/exchain/go-exchain/exchain/chaindb"
nebulav1
"github.com/exchain/go-exchain/exchain/protocol/gen/go/nebula/v1"
nebulav1
"github.com/exchain/go-exchain/exchain/protocol/gen/go/nebula/v1"
...
@@ -16,6 +18,7 @@ import (
...
@@ -16,6 +18,7 @@ import (
// Engine 实现订单撮合引擎
// Engine 实现订单撮合引擎
type
Engine
struct
{
type
Engine
struct
{
log
log
.
Logger
db
*
database
.
DexDB
db
*
database
.
DexDB
orderbooks
map
[
string
]
*
orderbook
.
OrderBook
orderbooks
map
[
string
]
*
orderbook
.
OrderBook
chainDB
chaindb
.
ChainDB
chainDB
chaindb
.
ChainDB
...
@@ -23,6 +26,8 @@ type Engine struct {
...
@@ -23,6 +26,8 @@ type Engine struct {
sync
.
Mutex
sync
.
Mutex
}
}
var
_
exchain
.
Engine
=
(
*
Engine
)(
nil
)
var
eg
*
Engine
var
eg
*
Engine
func
GetEngine
()
*
Engine
{
func
GetEngine
()
*
Engine
{
...
@@ -33,12 +38,12 @@ func GetEngine() *Engine {
...
@@ -33,12 +38,12 @@ func GetEngine() *Engine {
}
}
// NewEngine 创建一个新的订单撮合引擎
// NewEngine 创建一个新的订单撮合引擎
func
NewEngine
(
chainDB
chaindb
.
ChainDB
)
*
Engine
{
func
NewEngine
(
dataroot
string
,
log
log
.
Logger
,
chainDB
chaindb
.
ChainDB
)
*
Engine
{
if
eg
!=
nil
{
if
eg
!=
nil
{
return
eg
return
eg
}
}
lvdb
,
err
:=
leveldb
.
New
(
"data/dexdb"
,
1024
,
1024
,
"dex
data"
,
false
)
lvdb
,
err
:=
leveldb
.
New
(
fmt
.
Sprintf
(
"%s/orderdata"
,
dataroot
),
1024
,
1024
,
"order
data"
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
...
@@ -49,6 +54,7 @@ func NewEngine(chainDB chaindb.ChainDB) *Engine {
...
@@ -49,6 +54,7 @@ func NewEngine(chainDB chaindb.ChainDB) *Engine {
}
}
eg
=
&
Engine
{
eg
=
&
Engine
{
log
:
log
,
db
:
db
,
db
:
db
,
orderbooks
:
make
(
map
[
string
]
*
orderbook
.
OrderBook
),
orderbooks
:
make
(
map
[
string
]
*
orderbook
.
OrderBook
),
chainDB
:
chainDB
,
chainDB
:
chainDB
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment