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
875ff0f5
Commit
875ff0f5
authored
Nov 06, 2019
by
jiangpeng
Committed by
vipwzw
Nov 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mempool:adapt chain33 skiplist
parent
5b1424ea
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
0 deletions
+12
-0
cache.go
plugin/mempool/price/cache.go
+4
-0
cache_test.go
plugin/mempool/price/cache_test.go
+2
-0
cache.go
plugin/mempool/score/cache.go
+4
-0
cache_test.go
plugin/mempool/score/cache_test.go
+2
-0
No files found.
plugin/mempool/price/cache.go
View file @
875ff0f5
...
@@ -37,6 +37,10 @@ func (item *priceScore) Compare(cmp skiplist.Scorer) int {
...
@@ -37,6 +37,10 @@ func (item *priceScore) Compare(cmp skiplist.Scorer) int {
return
skiplist
.
Small
return
skiplist
.
Small
}
}
func
(
item
*
priceScore
)
ByteSize
()
int64
{
return
int64
(
proto
.
Size
(
item
.
Value
))
}
// NewQueue 创建队列
// NewQueue 创建队列
func
NewQueue
(
subcfg
subConfig
)
*
Queue
{
func
NewQueue
(
subcfg
subConfig
)
*
Queue
{
return
&
Queue
{
return
&
Queue
{
...
...
plugin/mempool/price/cache_test.go
View file @
875ff0f5
...
@@ -115,6 +115,7 @@ func TestTimeCompetition(t *testing.T) {
...
@@ -115,6 +115,7 @@ func TestTimeCompetition(t *testing.T) {
cache
.
Push
(
item3
)
cache
.
Push
(
item3
)
assert
.
Equal
(
t
,
false
,
cache
.
Exist
(
string
(
item1
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
false
,
cache
.
Exist
(
string
(
item1
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
true
,
cache
.
Exist
(
string
(
item3
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
true
,
cache
.
Exist
(
string
(
item3
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
int64
(
item3
.
Value
.
Size
()),
cache
.
GetCacheBytes
())
}
}
func
TestPriceCompetition
(
t
*
testing
.
T
)
{
func
TestPriceCompetition
(
t
*
testing
.
T
)
{
...
@@ -123,6 +124,7 @@ func TestPriceCompetition(t *testing.T) {
...
@@ -123,6 +124,7 @@ func TestPriceCompetition(t *testing.T) {
cache
.
Push
(
item4
)
cache
.
Push
(
item4
)
assert
.
Equal
(
t
,
false
,
cache
.
Exist
(
string
(
item3
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
false
,
cache
.
Exist
(
string
(
item3
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
true
,
cache
.
Exist
(
string
(
item4
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
true
,
cache
.
Exist
(
string
(
item4
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
int64
(
item4
.
Value
.
Size
()),
cache
.
GetCacheBytes
())
}
}
func
TestAddDuplicateItem
(
t
*
testing
.
T
)
{
func
TestAddDuplicateItem
(
t
*
testing
.
T
)
{
...
...
plugin/mempool/score/cache.go
View file @
875ff0f5
...
@@ -42,6 +42,10 @@ func (item *scoreScore) Compare(cmp skiplist.Scorer) int {
...
@@ -42,6 +42,10 @@ func (item *scoreScore) Compare(cmp skiplist.Scorer) int {
return
skiplist
.
Small
return
skiplist
.
Small
}
}
func
(
item
*
scoreScore
)
ByteSize
()
int64
{
return
int64
(
proto
.
Size
(
item
.
Value
))
}
// NewQueue 创建队列
// NewQueue 创建队列
func
NewQueue
(
subcfg
subConfig
)
*
Queue
{
func
NewQueue
(
subcfg
subConfig
)
*
Queue
{
return
&
Queue
{
return
&
Queue
{
...
...
plugin/mempool/score/cache_test.go
View file @
875ff0f5
...
@@ -116,6 +116,7 @@ func TestTimeCompetition(t *testing.T) {
...
@@ -116,6 +116,7 @@ func TestTimeCompetition(t *testing.T) {
cache
.
Push
(
item3
)
cache
.
Push
(
item3
)
assert
.
Equal
(
t
,
false
,
cache
.
Exist
(
string
(
item1
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
false
,
cache
.
Exist
(
string
(
item1
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
true
,
cache
.
Exist
(
string
(
item3
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
true
,
cache
.
Exist
(
string
(
item3
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
int64
(
item3
.
Value
.
Size
()),
cache
.
GetCacheBytes
())
}
}
func
TestPriceCompetition
(
t
*
testing
.
T
)
{
func
TestPriceCompetition
(
t
*
testing
.
T
)
{
...
@@ -124,6 +125,7 @@ func TestPriceCompetition(t *testing.T) {
...
@@ -124,6 +125,7 @@ func TestPriceCompetition(t *testing.T) {
cache
.
Push
(
item4
)
cache
.
Push
(
item4
)
assert
.
Equal
(
t
,
false
,
cache
.
Exist
(
string
(
item3
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
false
,
cache
.
Exist
(
string
(
item3
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
true
,
cache
.
Exist
(
string
(
item4
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
true
,
cache
.
Exist
(
string
(
item4
.
Value
.
Hash
())))
assert
.
Equal
(
t
,
int64
(
item4
.
Value
.
Size
()),
cache
.
GetCacheBytes
())
}
}
func
TestAddDuplicateItem
(
t
*
testing
.
T
)
{
func
TestAddDuplicateItem
(
t
*
testing
.
T
)
{
...
...
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