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
94d25a83
Commit
94d25a83
authored
Oct 18, 2019
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
70604b60
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
58 deletions
+2
-58
go.mod
go.mod
+2
-0
util.go
plugin/consensus/dpos/types/util.go
+0
-39
util_test.go
plugin/consensus/dpos/types/util_test.go
+0
-19
No files found.
go.mod
View file @
94d25a83
...
...
@@ -20,6 +20,8 @@ require (
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.3.2
github.com/hashicorp/golang-lru v0.5.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.8.0
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
...
...
plugin/consensus/dpos/types/util.go
View file @
94d25a83
...
...
@@ -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 @
94d25a83
...
...
@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"os"
"os/signal"
"strings"
"sync"
"testing"
...
...
@@ -83,13 +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
...
...
@@ -116,17 +108,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