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

add more subnet log message #1257

Merged
merged 2 commits into from
Jul 9, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions docs/specifications/cli_user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,11 @@ The max-tx-in-block parameter is used to set the maximum transaction number of a
#### 1.1.4 P2P Network Parameters

--networkid
The networkid parameter is used to specify the network ID. Different networkids cannot connect to the blockchain network. 1=main net, 2=polaris test net, 3=testmode, and other for custom network.
The networkid parameter is used to specify the network ID. Different networkids cannot connect to the blockchain network. 1=main net, 2=polaris test net, 3=testmode, and other for custom network. The default value is 1.

--nodeport
The nodeport parameter is used to specify the P2P network port number. The default value is 20338.

--consensusport
The consensusport parameter specifies the consensus network port number. By default, the consensus network reuses the P2P network, so it is not necessary to specify a consensus network port. After the dual network is enabled with the --dual-port parameter, the consensus network port number must be set separately. The default is 20339.

--dual-port
The dual-port parameter initiates a dual network, i.e. a P2P network for processing transaction messages and a consensus network for consensus messages. The parameter disables by default.

--httpinfo-port
httpinfo-port parameter specifies the http server port of viewing node information. The default value is 0 which means closes the http server.

Expand Down
7 changes: 1 addition & 6 deletions docs/specifications/cli_user_guide_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,11 @@ max-tx-in-block 参数用于设置区块最大的交易数量。默认值是5000
#### 1.1.4 P2P网络参数

--networkid
networkid 参数用于指定网络ID,networkid不同将无法连接到区块链网络中。1:主网, 2:polaris测试网络, 3:testmode测试网, 其他的是用户自定义网络。
networkid 参数用于指定网络ID,networkid不同将无法连接到区块链网络中。1:主网, 2:polaris测试网络, 3:testmode测试网, 其他的是用户自定义网络。默认值为1。

--nodeport
nodeport 参数用于指定P2P网络端口号,默认值为20338。

--consensus-port
consensus-port 参数用于指定共识网络端口号。默认情况下,共识网络复用P2P网络,因此不需要指定共识网络端口,在通过--dual-port参数启动双网络后,则需要单独设置共识网络端口号。默认值为20339。

--dual-port
dual-port 参数启动双网络,即用于处理交易消息的P2P网络,和用于共识消息的共识网络。默认不开启。

--httpinfo-port
httpinfo-port 参数用于指定查看节点信息的http server端口。默认为0,表示不开启。
Expand Down
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,21 @@ func initAccount(ctx *cli.Context) (*account.Account, error) {
}
walletFile := ctx.GlobalString(utils.GetFlagName(utils.WalletFileFlag))
if walletFile == "" {
return nil, fmt.Errorf("Please config wallet file using --wallet flag")
return nil, fmt.Errorf("please config wallet file using --wallet flag")
}
if !common.FileExisted(walletFile) {
return nil, fmt.Errorf("Cannot find wallet file: %s. Please create a wallet first", walletFile)
return nil, fmt.Errorf("cannot find wallet file: %s. Please create a wallet first", walletFile)
}

acc, err := cmdcom.GetAccount(ctx)
if err != nil {
return nil, fmt.Errorf("get account error: %s", err)
}
log.Infof("Using account: %s", acc.Address.ToBase58())
pubKey := hex.EncodeToString(keypair.SerializePublicKey(acc.PublicKey))
log.Infof("Using account: %s, pubkey: %s", acc.Address.ToBase58(), pubKey)

if config.DefConfig.Genesis.ConsensusType == config.CONSENSUS_TYPE_SOLO {
curPk := hex.EncodeToString(keypair.SerializePublicKey(acc.PublicKey))
config.DefConfig.Genesis.SOLO.Bookkeepers = []string{curPk}
config.DefConfig.Genesis.SOLO.Bookkeepers = []string{pubKey}
}

log.Infof("Account init success")
Expand All @@ -270,7 +270,7 @@ func initLedger(ctx *cli.Context, stateHashHeight uint32) (*ledger.Ledger, error
}
err = ledger.DefLedger.Init(bookKeepers, genesisBlock)
if err != nil {
return nil, fmt.Errorf("Init ledger error: %s", err)
return nil, fmt.Errorf("init ledger error: %s", err)
}

log.Infof("Ledger init success")
Expand All @@ -283,7 +283,7 @@ func initTxPool(ctx *cli.Context) (*proc.TXPoolServer, error) {
disableBroadcastNetTx := ctx.GlobalBool(utils.GetFlagName(utils.DisableBroadcastNetTxFlag))
txPoolServer, err := txnpool.StartTxnPoolServer(disablePreExec, disableBroadcastNetTx)
if err != nil {
return nil, fmt.Errorf("Init txpool error: %s", err)
return nil, fmt.Errorf("init txpool error: %s", err)
}
stlValidator, _ := stateless.NewValidator("stateless_validator")
stlValidator.Register(txPoolServer.GetPID(tc.VerifyRspActor))
Expand Down
8 changes: 8 additions & 0 deletions p2pserver/message/types/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ func (self *SubnetMembersRequest) FromSeed() bool {
return self.Timestamp == 0
}

func (self *SubnetMembersRequest) Role() string {
if self.FromSeed() {
return "seed"
}

return "gov"
}

func NewMembersRequest(from, to common.PeerId, acc *account.Account) (*SubnetMembersRequest, error) {
request := &SubnetMembersRequest{
From: from,
Expand Down
13 changes: 6 additions & 7 deletions p2pserver/protocols/subnet/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,12 @@ func (self *SubNet) OnMembersRequest(ctx *p2p.Context, msg *types.SubnetMembersR
}

func (self *SubNet) OnMembersResponse(ctx *p2p.Context, msg *types.SubnetMembers) {
sender := ctx.Sender()
self.lock.Lock()
defer self.lock.Unlock()
self.logger.Debugf("[subnet] receive members: %s ", msg.String())
self.logger.Debugf("[subnet] receive members from peer %s, value: %s ", sender.Info.Id.ToHexString(), msg.String())

listen := ctx.Sender().Info.RemoteListenAddress()
listen := sender.Info.RemoteListenAddress()
if self.connected[listen] == nil {
self.logger.Info("[subnet] receive members response from unkown node: %s", listen)
return
Expand Down Expand Up @@ -283,11 +284,7 @@ func (self *SubNet) sendMembersRequestToRandNodes(net p2p.P2P) {
self.lock.RUnlock()

for _, peerId := range peerIds {
request := self.newMembersRequest(net.GetID(), peerId)
if request == nil {
return
}
net.SendTo(peerId, request)
self.sendMembersRequest(net, peerId)
}
}

Expand All @@ -297,6 +294,8 @@ func (self *SubNet) sendMembersRequest(net p2p.P2P, peer common.PeerId) {
return
}

self.logger.Infof("[subnet] send member request from %s to %s as role %s",
request.From, request.To, request.Role())
net.SendTo(peer, request)
}

Expand Down