Commit 4a632a93 authored by suyanlong's avatar suyanlong

fix bug

parent 58cc8183
Pipeline #8624 failed with stages
......@@ -37,7 +37,7 @@ type App struct {
manger internal.Launcher
apiServer *api.Server
managerPort *appchain.Manager
appManagerPort *appchain.Manager
}
// NewSidecar instantiates sidecar instance.
......@@ -78,7 +78,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
config: config,
manger: mg,
apiServer: apiServer,
managerPort: managerPort,
appManagerPort: managerPort,
}, nil
}
......@@ -88,7 +88,7 @@ func (s *App) Start() error {
return err
}
if err := s.managerPort.Start(); err != nil {
if err := s.appManagerPort.Start(); err != nil {
return err
}
......@@ -97,13 +97,5 @@ func (s *App) Start() error {
// Stop stops three main components of sidecar app
func (s *App) Stop() error {
if err := s.apiServer.Stop(); err != nil {
return err
}
if err := s.managerPort.Stop(); err != nil {
return err
}
return s.manger.Stop()
return tool.SelectError(s.apiServer.Stop(), s.appManagerPort.Stop(), s.manger.Stop())
}
......@@ -30,7 +30,7 @@ type appChain struct {
logger logrus.FieldLogger
ctx context.Context
cancel context.CancelFunc
cryptor txcrypto.Cryptor
cryptor txcrypto.Cryptor //TODO FIX BUG
msgCh chan *pb.Message
}
......@@ -147,7 +147,7 @@ func (a *appChain) applyReceiptIBTP(ibtp *pb.IBTP) error {
contentByte := pd.Content
var err error
if pd.Encrypted {
if pd.Encrypted { //TODO
// TODO fix bug about mode value
contentByte, err = a.cryptor.Decrypt(contentByte, ibtp.To, repo.DirectMode)
if err != nil {
......
......@@ -3,9 +3,6 @@ package peermgr
import (
"context"
"fmt"
"sync"
"time"
"github.com/Rican7/retry"
"github.com/Rican7/retry/strategy"
cid "github.com/ipfs/go-cid"
......@@ -13,6 +10,8 @@ import (
"github.com/meshplus/bitxhub-kit/crypto"
network "github.com/meshplus/go-lightp2p"
"github.com/sirupsen/logrus"
"sync"
"time"
"gitlab.33.cn/link33/sidecar/internal/port"
"gitlab.33.cn/link33/sidecar/internal/repo"
......@@ -132,20 +131,21 @@ func (swarm *Swarm) Start() error {
for id, addr := range swarm.peers {
go func(remoteID string, addr *peer.AddrInfo) {
if err := retry.Retry(func(attempt uint) error {
if err := swarm.p2p.Connect(*addr); err != nil {
if attempt != 0 && attempt%5 == 0 {
err := retry.Retry(func(attempt uint) error {
err := swarm.p2p.Connect(*addr)
if err != nil {
swarm.logger.WithFields(logrus.Fields{
"node": remoteID,
"error": err,
}).Error("Connect failed")
}
"attempt": attempt,
}).Error("Connect failed", err)
return err
}
return nil
}, strategy.Wait(1*time.Second)); err != nil {
}, strategy.Limit(5), strategy.Wait(time.Second))
if err != nil {
swarm.logger.Error(err)
}
} else {
address, err := swarm.getRemoteAddress(addr.ID)
if err != nil {
swarm.logger.WithFields(logrus.Fields{
......@@ -167,6 +167,7 @@ func (swarm *Swarm) Start() error {
// }(handler, address)
//}
}
}
wg.Done()
}(id, addr)
}
......
......@@ -106,7 +106,8 @@ func (r *router) Remove(p port.Port) error {
// 路由的有那些数据?需要区分!!!
func (r *router) Route(msg *pb.Message) error {
if msg == nil {
r.logger.Error("msg = nil")
r.logger.Error("msg == nil")
return errors.New("msg == nil")
}
ibtpx := &pb.IBTPX{}
err := ibtpx.Unmarshal(msg.Payload.Data)
......@@ -194,8 +195,8 @@ func (r *router) Route(msg *pb.Message) error {
r.logger.Error(err)
return err
}
case pb.Message_IBTP_GET:
case pb.Message_IBTP_RECEIPT_GET:
case pb.Message_IBTP_GET: //TODO
case pb.Message_IBTP_RECEIPT_GET: //TODO
default:
return nil
}
......
......@@ -7,11 +7,11 @@ import "basic.proto";
// Inter-blockchain Transfer Protocol
message IBTP {
enum Type {
INTERCHAIN = 0;
RECEIPT_SUCCESS = 1;
RECEIPT_FAILURE = 2;
ROLLBACK = 3;
RECEIPT_ROLLBACK = 4;
INTERCHAIN = 0; // 发送跨链交易。
RECEIPT_SUCCESS = 1; // 接收成功
RECEIPT_FAILURE = 2; // 接收失败
ROLLBACK = 3; // 回滚
RECEIPT_ROLLBACK = 4; // 接收回滚
}
enum Category {
......
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