Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
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
sidecar
Commits
b84f1a6e
Commit
b84f1a6e
authored
Sep 15, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed local bug
parent
3e01e21c
Pipeline
#7994
canceled with stages
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
24 deletions
+17
-24
local.go
internal/peermgr/local.go
+10
-5
peermgr.go
internal/peermgr/peermgr.go
+4
-7
swarm.go
internal/peermgr/swarm.go
+1
-7
interface.go
internal/router/interface.go
+2
-5
No files found.
internal/peermgr/local.go
View file @
b84f1a6e
...
...
@@ -3,11 +3,10 @@ package peermgr
import
(
"errors"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/sirupsen/logrus"
"github.com/link33/sidecar/internal/port"
"github.com/link33/sidecar/internal/router"
"github.com/link33/sidecar/model/pb"
"github.com/meshplus/bitxhub-kit/crypto"
"github.com/sirupsen/logrus"
)
var
(
...
...
@@ -17,13 +16,19 @@ var (
type
local
struct
{
id
peer
.
ID
privKey
crypto
.
PrivateKey
tag
string
rev
chan
*
pb
.
Message
rout
router
.
Router
logger
logrus
.
FieldLogger
}
func
newLocal
(
id
peer
.
ID
)
*
local
{
return
&
local
{
id
:
id
,
tag
:
Office
,
rev
:
make
(
chan
*
pb
.
Message
,
10
),
}
}
func
(
l
*
local
)
ID
()
string
{
return
l
.
id
.
String
()
}
...
...
internal/peermgr/peermgr.go
View file @
b84f1a6e
...
...
@@ -2,6 +2,7 @@ package peermgr
import
(
"github.com/libp2p/go-libp2p-core/peer"
"github.com/link33/sidecar/internal"
"github.com/link33/sidecar/internal/port"
"github.com/link33/sidecar/model/pb"
)
...
...
@@ -11,13 +12,11 @@ type ConnectHandler func(string)
//go:generate mockgen -destination mock_peermgr/mock_peermgr.go -package mock_peermgr -source peermgr.go
type
PeerManager
interface
{
DHTManag
er
internal
.
Launch
er
// Start
Start
()
error
DHTManager
// Stop
Stop
()
error
Handler
Connect
(
info
*
peer
.
AddrInfo
)
(
string
,
error
)
...
...
@@ -31,8 +30,6 @@ type PeerManager interface {
SendWithPort
(
s
port
.
Port
,
msg
*
pb
.
Message
)
(
*
pb
.
Message
,
error
)
GetRemotePeerInfo
(
id
string
)
(
*
pb
.
PeerInfo
,
error
)
Handler
}
type
Handler
interface
{
...
...
internal/peermgr/swarm.go
View file @
b84f1a6e
...
...
@@ -103,13 +103,7 @@ func (swarm *Swarm) Start() error {
if
err
!=
nil
{
return
err
}
l
:=
&
local
{
id
:
swarm
.
id
,
privKey
:
swarm
.
privKey
,
tag
:
Office
,
rev
:
make
(
chan
*
pb
.
Message
),
rout
:
swarm
.
router
,
}
l
:=
newLocal
(
swarm
.
id
)
swarm
.
add
(
l
)
swarm
.
p2p
.
SetMessageHandler
(
swarm
.
handleMessage
)
if
err
:=
swarm
.
RegisterMsgHandler
(
pb
.
Message_ADDRESS_GET
,
swarm
.
handleGetAddressMessage
);
err
!=
nil
{
...
...
internal/router/interface.go
View file @
b84f1a6e
package
router
import
(
"github.com/link33/sidecar/internal"
"github.com/link33/sidecar/internal/port"
"github.com/link33/sidecar/model/pb"
)
//go:generate mockgen -destination mock_router/mock_router.go -package mock_router -source interface.go
type
Router
interface
{
// Start starts the router module
Start
()
error
// Stop
Stop
()
error
internal
.
Launcher
Add
(
p
port
.
Port
)
error
...
...
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