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
0ea23ead
Commit
0ea23ead
authored
Dec 03, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add block compact db
parent
bccd48b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
kvmvcc_mavl.go
plugin/store/kvmvccmavl/kvmvcc_mavl.go
+16
-2
No files found.
plugin/store/kvmvccmavl/kvmvcc_mavl.go
View file @
0ea23ead
...
@@ -277,6 +277,20 @@ func (kvmMavls *KVmMavlStore) MemSet(datas *types.StoreSet, sync bool) ([]byte,
...
@@ -277,6 +277,20 @@ func (kvmMavls *KVmMavlStore) MemSet(datas *types.StoreSet, sync bool) ([]byte,
// 对删除的mavl进行压缩
// 对删除的mavl进行压缩
if
isDelMavlData
&&
!
isCompactDelMavl
&&
!
isDelMavling
()
{
if
isDelMavlData
&&
!
isCompactDelMavl
&&
!
isDelMavling
()
{
go
CompactDelMavl
(
kvmMavls
.
GetDB
())
go
CompactDelMavl
(
kvmMavls
.
GetDB
())
if
datas
.
Height
>
delMavlDataHeight
&&
datas
.
Height
<
delMavlDataHeight
*
2
{
// 出于对区块链安全的角度阻塞执行区块压缩之发生在固定高度区间内
count
:=
0
for
{
if
quit
||
isCompactDelMavl
{
break
}
if
count
%
100
==
0
{
kmlog
.
Info
(
"block compact db"
,
"count time s"
,
count
)
}
count
++
time
.
Sleep
(
time
.
Second
)
}
}
}
}
return
hash
,
err
return
hash
,
err
}
}
...
@@ -518,13 +532,13 @@ func CompactDelMavl(db dbm.DB) {
...
@@ -518,13 +532,13 @@ func CompactDelMavl(db dbm.DB) {
setDelMavl
(
delMavlStateStart
)
setDelMavl
(
delMavlStateStart
)
defer
setDelMavl
(
delMavlStateEnd
)
defer
setDelMavl
(
delMavlStateEnd
)
// 开始进行压缩处理
// 开始进行压缩处理
kmlog
.
Info
(
"start
C
ompact db"
)
kmlog
.
Info
(
"start
c
ompact db"
)
err
:=
db
.
CompactRange
(
nil
,
nil
)
err
:=
db
.
CompactRange
(
nil
,
nil
)
if
err
==
nil
{
if
err
==
nil
{
db
.
Set
(
genCompactDelMavlKey
(
mvccPrefix
),
[]
byte
(
""
))
db
.
Set
(
genCompactDelMavlKey
(
mvccPrefix
),
[]
byte
(
""
))
isCompactDelMavl
=
true
isCompactDelMavl
=
true
}
}
kmlog
.
Info
(
"end
C
ompact db"
,
"error"
,
err
)
kmlog
.
Info
(
"end
c
ompact db"
,
"error"
,
err
)
}
}
func
genCompactDelMavlKey
(
prefix
[]
byte
)
[]
byte
{
func
genCompactDelMavlKey
(
prefix
[]
byte
)
[]
byte
{
...
...
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