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
a413a97a
Unverified
Commit
a413a97a
authored
Oct 18, 2019
by
vipwzw
Committed by
GitHub
Oct 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #691 from zzh33cn/dpos-v2
删除DPos部分无用代码及UT
parents
c05c19a5
014ca885
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
59 deletions
+0
-59
util.go
plugin/consensus/dpos/types/util.go
+0
-39
util_test.go
plugin/consensus/dpos/types/util_test.go
+0
-20
No files found.
plugin/consensus/dpos/types/util.go
View file @
a413a97a
...
...
@@ -11,7 +11,6 @@ import (
"os"
"path/filepath"
"sync"
"syscall"
"time"
)
...
...
@@ -88,50 +87,12 @@ func Fingerprint(slice []byte) []byte {
return
fingerprint
}
// Kill ...
func
Kill
()
error
{
p
,
err
:=
os
.
FindProcess
(
os
.
Getpid
())
if
err
!=
nil
{
return
err
}
return
p
.
Signal
(
syscall
.
SIGTERM
)
}
// Exit ...
func
Exit
(
s
string
)
{
fmt
.
Printf
(
s
+
"
\n
"
)
os
.
Exit
(
1
)
}
// Parallel ...
func
Parallel
(
tasks
...
func
())
{
var
wg
sync
.
WaitGroup
wg
.
Add
(
len
(
tasks
))
for
_
,
task
:=
range
tasks
{
go
func
(
task
func
())
{
task
()
wg
.
Done
()
}(
task
)
}
wg
.
Wait
()
}
// MinInt ...
func
MinInt
(
a
,
b
int
)
int
{
if
a
<
b
{
return
a
}
return
b
}
// MaxInt ...
func
MaxInt
(
a
,
b
int
)
int
{
if
a
>
b
{
return
a
}
return
b
}
// RandIntn ...
func
RandIntn
(
n
int
)
int
{
if
n
<=
0
{
...
...
plugin/consensus/dpos/types/util_test.go
View file @
a413a97a
...
...
@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"os"
"os/signal"
"strings"
"sync"
"testing"
...
...
@@ -83,14 +82,6 @@ func TestFingerprint(t *testing.T) {
assert
.
True
(
t
,
bytes
.
Equal
(
finger
,
arr
[
0
:
6
]))
}
func
TestKill
(
t
*
testing
.
T
)
{
c
:=
make
(
chan
os
.
Signal
)
signal
.
Notify
(
c
)
go
Kill
()
s
:=
<-
c
assert
.
True
(
t
,
s
.
String
()
==
"terminated"
)
}
var
(
goIndex
=
0
goIndexMutex
sync
.
Mutex
...
...
@@ -116,17 +107,6 @@ func TestParallel(t *testing.T) {
f2
:=
test
f2
()
assert
.
True
(
t
,
goSum
==
2
)
/*
goSumMutex.Lock()
goSum = 0
goSumMutex.Unlock()
Parallel(f1, f2)
goSumMutex.Lock()
assert.True(t, goSum == 2)
goSumMutex.Unlock()
*/
}
func
TestRandInt63n
(
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