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
f23e3cf1
Commit
f23e3cf1
authored
Dec 28, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug
parent
115d161d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
19 deletions
+12
-19
start.go
cmd/sidecar/start.go
+0
-8
sidecar.go
internal/app/sidecar.go
+3
-6
router.go
internal/router/router.go
+9
-5
No files found.
cmd/sidecar/start.go
View file @
f23e3cf1
...
@@ -57,10 +57,7 @@ func start(ctx *cli.Context) error {
...
@@ -57,10 +57,7 @@ func start(ctx *cli.Context) error {
}
}
// init loggers map for sidecar
// init loggers map for sidecar
loggers
.
InitializeLogger
(
config
)
loggers
.
InitializeLogger
(
config
)
var
sidecar
internal
.
Launcher
var
sidecar
internal
.
Launcher
fmt
.
Println
(
repoRoot
)
fmt
.
Println
(
config
)
sidecar
,
err
=
app
.
NewSidecar
(
repoRoot
,
config
)
sidecar
,
err
=
app
.
NewSidecar
(
repoRoot
,
config
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -68,17 +65,13 @@ func start(ctx *cli.Context) error {
...
@@ -68,17 +65,13 @@ func start(ctx *cli.Context) error {
httpPProf
(
config
.
Port
.
PProf
)
httpPProf
(
config
.
Port
.
PProf
)
runtimePProf
()
runtimePProf
()
var
wg
sync
.
WaitGroup
var
wg
sync
.
WaitGroup
wg
.
Add
(
1
)
wg
.
Add
(
1
)
handleShutdown
(
sidecar
,
&
wg
)
handleShutdown
(
sidecar
,
&
wg
)
if
err
:=
sidecar
.
Start
();
err
!=
nil
{
if
err
:=
sidecar
.
Start
();
err
!=
nil
{
return
err
return
err
}
}
wg
.
Wait
()
wg
.
Wait
()
logger
.
Info
(
"App exits"
)
logger
.
Info
(
"App exits"
)
return
nil
return
nil
}
}
...
@@ -87,7 +80,6 @@ func handleShutdown(sidecar internal.Launcher, wg *sync.WaitGroup) {
...
@@ -87,7 +80,6 @@ func handleShutdown(sidecar internal.Launcher, wg *sync.WaitGroup) {
stop
:=
make
(
chan
os
.
Signal
)
stop
:=
make
(
chan
os
.
Signal
)
signal
.
Notify
(
stop
,
syscall
.
SIGTERM
)
signal
.
Notify
(
stop
,
syscall
.
SIGTERM
)
signal
.
Notify
(
stop
,
syscall
.
SIGINT
)
signal
.
Notify
(
stop
,
syscall
.
SIGINT
)
go
func
()
{
go
func
()
{
<-
stop
<-
stop
fmt
.
Println
(
"received interrupt signal, shutting down..."
)
fmt
.
Println
(
"received interrupt signal, shutting down..."
)
...
...
internal/app/sidecar.go
View file @
f23e3cf1
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
_
"gitlab.33.cn/link33/sidecar/imports"
_
"gitlab.33.cn/link33/sidecar/imports"
"gitlab.33.cn/link33/sidecar/internal"
"gitlab.33.cn/link33/sidecar/internal"
"gitlab.33.cn/link33/sidecar/internal/appchain"
"gitlab.33.cn/link33/sidecar/internal/appchain"
"gitlab.33.cn/link33/sidecar/internal/checker"
"gitlab.33.cn/link33/sidecar/internal/loggers"
"gitlab.33.cn/link33/sidecar/internal/loggers"
"gitlab.33.cn/link33/sidecar/internal/manager"
"gitlab.33.cn/link33/sidecar/internal/manager"
"gitlab.33.cn/link33/sidecar/internal/peermgr"
"gitlab.33.cn/link33/sidecar/internal/peermgr"
...
@@ -51,12 +52,8 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
...
@@ -51,12 +52,8 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
tool
.
Asset
(
err
)
tool
.
Asset
(
err
)
nodePrivKey
,
err
:=
repo
.
LoadNodePrivateKey
(
repoRoot
)
nodePrivKey
,
err
:=
repo
.
LoadNodePrivateKey
(
repoRoot
)
tool
.
Asset
(
err
)
tool
.
Asset
(
err
)
var
(
ck
:=
&
checker
.
MockChecker
{}
//TODO
// ck checker.Checker
r
:=
router
.
NewRouter
(
privateKey
,
loggers
.
Logger
(
loggers
.
Router
),
ck
)
// cryptor txcrypto.Cryptor
// apiServer *apiServer.Server
)
r
:=
router
.
NewRouter
(
privateKey
,
loggers
.
Logger
(
loggers
.
Router
))
pm
,
err
:=
peermgr
.
New
(
config
,
r
,
nodePrivKey
,
privateKey
,
1
,
loggers
.
Logger
(
loggers
.
PeerMgr
))
pm
,
err
:=
peermgr
.
New
(
config
,
r
,
nodePrivKey
,
privateKey
,
1
,
loggers
.
Logger
(
loggers
.
PeerMgr
))
tool
.
Asset
(
err
)
tool
.
Asset
(
err
)
persister
:=
manager
.
NewPersister
(
addr
.
String
(),
store
,
loggers
.
Logger
(
loggers
.
Manager
))
persister
:=
manager
.
NewPersister
(
addr
.
String
(),
store
,
loggers
.
Logger
(
loggers
.
Manager
))
...
...
internal/router/router.go
View file @
f23e3cf1
...
@@ -29,7 +29,7 @@ type router struct {
...
@@ -29,7 +29,7 @@ type router struct {
type
routeMethod
func
([]
string
)
[]
port
.
Port
type
routeMethod
func
([]
string
)
[]
port
.
Port
func
NewRouter
(
privateKey
crypto
.
PrivateKey
,
logger
logrus
.
FieldLogger
)
Router
{
func
NewRouter
(
privateKey
crypto
.
PrivateKey
,
logger
logrus
.
FieldLogger
,
checker
checker
.
Checker
)
Router
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
return
&
router
{
return
&
router
{
logger
:
logger
,
logger
:
logger
,
...
@@ -38,7 +38,7 @@ func NewRouter(privateKey crypto.PrivateKey, logger logrus.FieldLogger) Router {
...
@@ -38,7 +38,7 @@ func NewRouter(privateKey crypto.PrivateKey, logger logrus.FieldLogger) Router {
portMap
:
port
.
NewPortMap
(),
portMap
:
port
.
NewPortMap
(),
methodMap
:
map
[
string
]
routeMethod
{},
methodMap
:
map
[
string
]
routeMethod
{},
privateKey
:
privateKey
,
privateKey
:
privateKey
,
checker
:
&
checker
.
MockChecker
{},
//TODO
checker
:
checker
,
}
}
}
}
...
@@ -310,12 +310,16 @@ func (r *router) aggVerify(ibtpx *pb.IBTPX) bool {
...
@@ -310,12 +310,16 @@ func (r *router) aggVerify(ibtpx *pb.IBTPX) bool {
if
len
(
ibtpx
.
RouteSign
)
>
0
{
if
len
(
ibtpx
.
RouteSign
)
>
0
{
err
:=
aggSign
.
DeserializeHexStr
(
ibtpx
.
RouteSign
[
0
])
err
:=
aggSign
.
DeserializeHexStr
(
ibtpx
.
RouteSign
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
r
.
logger
.
Error
(
"aggVerify error "
,
err
)
return
false
return
false
}
}
pks
:=
&
blseth
.
PublicKey
{}
pks
:=
&
blseth
.
PublicKey
{}
for
_
,
val
:=
range
ibtpx
.
RouteSign
[
1
:
]
{
for
_
,
val
:=
range
ibtpx
.
RouteSign
[
1
:
]
{
pub
:=
&
blseth
.
PublicKey
{}
pub
:=
&
blseth
.
PublicKey
{}
_
=
pub
.
DeserializeHexStr
(
val
)
err
=
pub
.
DeserializeHexStr
(
val
)
if
err
!=
nil
{
r
.
logger
.
Error
(
"aggVerify error "
,
err
)
}
pks
.
Add
(
pub
)
pks
.
Add
(
pub
)
}
}
return
aggSign
.
VerifyByte
(
pks
,
ibtpx
.
FrontPart
())
return
aggSign
.
VerifyByte
(
pks
,
ibtpx
.
FrontPart
())
...
@@ -356,7 +360,7 @@ func (r *router) Send(id string, msg *pb.Message) (*pb.Message, error) {
...
@@ -356,7 +360,7 @@ func (r *router) Send(id string, msg *pb.Message) (*pb.Message, error) {
return
p
.
Send
(
msg
)
return
p
.
Send
(
msg
)
}
}
return
nil
,
errors
.
New
(
"id
error
!"
)
return
nil
,
errors
.
New
(
"id
not exist
!"
)
}
}
func
(
r
*
router
)
AsyncSend
(
id
string
,
msg
*
pb
.
Message
)
error
{
func
(
r
*
router
)
AsyncSend
(
id
string
,
msg
*
pb
.
Message
)
error
{
...
@@ -364,7 +368,7 @@ func (r *router) AsyncSend(id string, msg *pb.Message) error {
...
@@ -364,7 +368,7 @@ func (r *router) AsyncSend(id string, msg *pb.Message) error {
return
p
.
AsyncSend
(
msg
)
return
p
.
AsyncSend
(
msg
)
}
}
return
errors
.
New
(
"id
error
!"
)
return
errors
.
New
(
"id
not exist
!"
)
}
}
type
RouteMethod
interface
{
type
RouteMethod
interface
{
...
...
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