Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
link33
plugin
Commits
38f7fb5f
Commit
38f7fb5f
authored
Jan 15, 2020
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加 trade Upgrade
parent
11c2be11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
localdb_v1.go
plugin/dapp/trade/executor/localdb_v1.go
+12
-6
No files found.
plugin/dapp/trade/executor/localdb_v1.go
View file @
38f7fb5f
...
@@ -29,16 +29,21 @@ const (
...
@@ -29,16 +29,21 @@ const (
orderASTHK
=
"LODB-trade-order-asthk:"
orderASTHK
=
"LODB-trade-order-asthk:"
)
)
// Upgrade 实现升级接口
func
(
t
*
trade
)
Upgrade
()
error
{
localDB
:=
t
.
GetLocalDB
()
return
TradeUpdateLocalDBV2
(
localDB
,
0
)
}
// TradeUpdateLocalDBV2 trade 本地数据库升级
// TradeUpdateLocalDBV2 trade 本地数据库升级
// from 1 to 2
// from 1 to 2
func
TradeUpdateLocalDBV2
(
localDB
dbm
.
DB
,
total
int
)
error
{
func
TradeUpdateLocalDBV2
(
localDB
dbm
.
KV
DB
,
total
int
)
error
{
// 外部不指定, 强制分批执行
// 外部不指定, 强制分批执行
if
total
<=
0
{
if
total
<=
0
{
total
=
10000
total
=
10000
}
}
toVersion
:=
2
toVersion
:=
2
kvdb
:=
dbm
.
NewKVDB
(
localDB
)
version
,
err
:=
getVersion
(
localDB
)
version
,
err
:=
getVersion
(
kvdb
)
if
err
!=
nil
{
if
err
!=
nil
{
tradelog
.
Error
(
"TradeUpdateLocalDBV2 get version"
,
"err"
,
err
)
tradelog
.
Error
(
"TradeUpdateLocalDBV2 get version"
,
"err"
,
err
)
return
errors
.
Cause
(
err
)
return
errors
.
Cause
(
err
)
...
@@ -47,15 +52,16 @@ func TradeUpdateLocalDBV2(localDB dbm.DB, total int) error {
...
@@ -47,15 +52,16 @@ func TradeUpdateLocalDBV2(localDB dbm.DB, total int) error {
return
nil
return
nil
}
}
err
=
UpdateLocalDBPart2
(
kvdb
,
total
)
err
=
UpdateLocalDBPart2
(
localDB
,
total
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
err
=
UpdateLocalDBPart1
(
localDB
,
total
)
// TODO input DB to KVDB
err
=
UpdateLocalDBPart1
(
nil
,
total
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
return
setVersion
(
kvdb
,
toVersion
)
return
setVersion
(
localDB
,
toVersion
)
}
}
// UpdateLocalDBPart1 手动生成KV,需要在原有数据库中删除
// UpdateLocalDBPart1 手动生成KV,需要在原有数据库中删除
...
...
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