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
d3b0a7fc
Commit
d3b0a7fc
authored
Oct 09, 2019
by
harrylee
Committed by
vipwzw
Oct 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajust code for fmt_check
parent
6bf4628e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
39 deletions
+2
-39
pbft_test.go
plugin/consensus/pbft/pbft_test.go
+0
-37
listener.go
plugin/consensus/raft/listener.go
+1
-1
raft.go
plugin/consensus/raft/raft.go
+1
-1
No files found.
plugin/consensus/pbft/pbft_test.go
View file @
d3b0a7fc
...
...
@@ -150,39 +150,3 @@ func clearTestData() {
}
fmt
.
Println
(
"test data clear successfully!"
)
}
func
TestReplica
(
t
*
testing
.
T
){
reply1
,
request1
,
isPrimary1
:=
NewReplica
(
1
,
"127.0.0.1:8891,127.0.0.1:8892,127.0.0.1:8893"
,
"127.0.0.1:8891"
)
reply2
,
request2
,
isPrimary2
:=
NewReplica
(
2
,
"127.0.0.1:8891,127.0.0.1:8892,127.0.0.1:8893"
,
"127.0.0.1:8892"
)
reply3
,
request3
,
isPrimary3
:=
NewReplica
(
3
,
"127.0.0.1:8891,127.0.0.1:8892,127.0.0.1:8893"
,
"127.0.0.1:8893"
)
go
func
()
{
for
{
select
{
case
<-
reply1
:
t
.
Log
(
"I'm have reply1 message"
)
case
<-
reply2
:
t
.
Log
(
"I'm have reply2 message"
)
case
<-
reply3
:
t
.
Log
(
"I'm have reply3 message"
)
}
}
}()
t
.
Log
(
isPrimary1
)
t
.
Log
(
isPrimary2
)
t
.
Log
(
isPrimary3
)
go
func
()
{
for
i
:=
0
;
i
<
100
;
i
++
{
op
:=
&
types
.
Operation
{
Value
:
&
types
.
Block
{}}
select
{
case
request1
<-
ToRequestClient
(
op
,
types
.
Now
()
.
String
(),
"127.0.0.1:8891"
)
:
t
.
Log
(
"I'm have send request1 message"
)
case
request2
<-
ToRequestClient
(
op
,
types
.
Now
()
.
String
(),
"127.0.0.1:8892"
)
:
t
.
Log
(
"I'm have send request2 message"
)
case
request3
<-
ToRequestClient
(
op
,
types
.
Now
()
.
String
(),
"127.0.0.1:8893"
)
:
t
.
Log
(
"I'm have send request3 message"
)
}
}
}()
time
.
Sleep
(
5
*
time
.
Second
)
}
\ No newline at end of file
plugin/consensus/raft/listener.go
View file @
d3b0a7fc
...
...
@@ -18,7 +18,7 @@ type stoppableListener struct {
}
// 监听tcp连接
func
newStoppableListener
(
addr
string
,
ctx
context
.
Context
)
(
*
stoppableListener
,
error
)
{
func
newStoppableListener
(
ctx
context
.
Context
,
addr
string
)
(
*
stoppableListener
,
error
)
{
ln
,
err
:=
net
.
Listen
(
"tcp"
,
addr
)
if
err
!=
nil
{
return
nil
,
err
...
...
plugin/consensus/raft/raft.go
View file @
d3b0a7fc
...
...
@@ -183,7 +183,7 @@ func (rc *raftNode) serveRaft() {
panic
(
err
)
}
ln
,
err
:=
newStoppableListener
(
nodeURL
.
Host
,
rc
.
ctx
)
ln
,
err
:=
newStoppableListener
(
rc
.
ctx
,
nodeURL
.
Host
)
if
err
!=
nil
{
rlog
.
Error
(
fmt
.
Sprintf
(
"raft: Failed to listen rafthttp (%v)"
,
err
.
Error
()))
panic
(
err
)
...
...
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