Commit f23e3cf1 authored by suyanlong's avatar suyanlong

Fixed bug

parent 115d161d
......@@ -57,10 +57,7 @@ func start(ctx *cli.Context) error {
}
// init loggers map for sidecar
loggers.InitializeLogger(config)
var sidecar internal.Launcher
fmt.Println(repoRoot)
fmt.Println(config)
sidecar, err = app.NewSidecar(repoRoot, config)
if err != nil {
return err
......@@ -68,17 +65,13 @@ func start(ctx *cli.Context) error {
httpPProf(config.Port.PProf)
runtimePProf()
var wg sync.WaitGroup
wg.Add(1)
handleShutdown(sidecar, &wg)
if err := sidecar.Start(); err != nil {
return err
}
wg.Wait()
logger.Info("App exits")
return nil
}
......@@ -87,7 +80,6 @@ func handleShutdown(sidecar internal.Launcher, wg *sync.WaitGroup) {
stop := make(chan os.Signal)
signal.Notify(stop, syscall.SIGTERM)
signal.Notify(stop, syscall.SIGINT)
go func() {
<-stop
fmt.Println("received interrupt signal, shutting down...")
......
......@@ -14,6 +14,7 @@ import (
_ "gitlab.33.cn/link33/sidecar/imports"
"gitlab.33.cn/link33/sidecar/internal"
"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/manager"
"gitlab.33.cn/link33/sidecar/internal/peermgr"
......@@ -51,12 +52,8 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
tool.Asset(err)
nodePrivKey, err := repo.LoadNodePrivateKey(repoRoot)
tool.Asset(err)
var (
// ck checker.Checker
// cryptor txcrypto.Cryptor
// apiServer *apiServer.Server
)
r := router.NewRouter(privateKey, loggers.Logger(loggers.Router))
ck := &checker.MockChecker{} //TODO
r := router.NewRouter(privateKey, loggers.Logger(loggers.Router), ck)
pm, err := peermgr.New(config, r, nodePrivKey, privateKey, 1, loggers.Logger(loggers.PeerMgr))
tool.Asset(err)
persister := manager.NewPersister(addr.String(), store, loggers.Logger(loggers.Manager))
......
......@@ -29,7 +29,7 @@ type router struct {
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())
return &router{
logger: logger,
......@@ -38,7 +38,7 @@ func NewRouter(privateKey crypto.PrivateKey, logger logrus.FieldLogger) Router {
portMap: port.NewPortMap(),
methodMap: map[string]routeMethod{},
privateKey: privateKey,
checker: &checker.MockChecker{}, //TODO
checker: checker,
}
}
......@@ -310,12 +310,16 @@ func (r *router) aggVerify(ibtpx *pb.IBTPX) bool {
if len(ibtpx.RouteSign) > 0 {
err := aggSign.DeserializeHexStr(ibtpx.RouteSign[0])
if err != nil {
r.logger.Error("aggVerify error ", err)
return false
}
pks := &blseth.PublicKey{}
for _, val := range ibtpx.RouteSign[1:] {
pub := &blseth.PublicKey{}
_ = pub.DeserializeHexStr(val)
err = pub.DeserializeHexStr(val)
if err != nil {
r.logger.Error("aggVerify error ", err)
}
pks.Add(pub)
}
return aggSign.VerifyByte(pks, ibtpx.FrontPart())
......@@ -356,7 +360,7 @@ func (r *router) Send(id string, msg *pb.Message) (*pb.Message, error) {
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 {
......@@ -364,7 +368,7 @@ func (r *router) AsyncSend(id string, msg *pb.Message) error {
return p.AsyncSend(msg)
}
return errors.New("id error!")
return errors.New("id not exist!")
}
type RouteMethod interface {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment