Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

兼容容器环境, 监听 ":port" #288

Merged
merged 3 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bcs/consensus/xpoa/xpoa.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (x *xpoaConsensus) CheckMinerMatch(ctx xcontext.XContext, block cctx.BlockI
// 包装成统一入口访问smr
err = x.smr.CheckProposal(block, justify, validators)
if err != nil {
x.log.Error("consensus:tdpos:CheckMinerMatch: bft IsQuorumCertValidate failed", "proposalQC:[height]", block.GetHeight(),
x.log.Error("consensus:xpoa:CheckMinerMatch: bft IsQuorumCertValidate failed", "proposalQC:[height]", block.GetHeight(),
"proposalQC:[id]", utils.F(block.GetBlockid()), "justifyQC:[height]", justify.GetProposalView(),
"justifyQC:[id]", utils.F(justify.GetProposalId()), "error", err)
return false, err
Expand Down Expand Up @@ -263,7 +263,7 @@ func (x *xpoaConsensus) ProcessBeforeMiner(timestamp int64) ([]byte, []byte, err
}
// 重做时还需要装载标定节点TipHeight,复用TargetBits作为回滚记录,便于追块时获取准确快照高度
if truncate {
x.log.Warn("consensus:tdpos:ProcessBeforeMiner: last block not confirmed, walk to previous block",
x.log.Warn("consensus:xpoa:ProcessBeforeMiner: last block not confirmed, walk to previous block",
"target", utils.F(qc.GetProposalId()), "ledger", tipBlock.GetHeight())
storage.TargetBits = int32(tipBlock.GetHeight())
bytes, _ := json.Marshal(storage)
Expand Down
7 changes: 7 additions & 0 deletions bcs/network/p2pv1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net"
"strings"
"time"

"github.com/golang/protobuf/proto"
Expand Down Expand Up @@ -142,6 +143,12 @@ func (p *P2PServerV1) serve() {
panic(fmt.Sprintf("address error: address=%s", err))
}

//Compatible container runtime, listening ":port"
portIndex := strings.LastIndex(ip, ":")
if portIndex > 0 {
ip = ip[portIndex:]
}

l, err := net.Listen(network, ip)
if err != nil {
panic(err)
Expand Down