Commit d4423f18 authored by madengji's avatar madengji Committed by 33cn

new p2p proc file

parent 61a9b28e
...@@ -27,7 +27,6 @@ import ( ...@@ -27,7 +27,6 @@ import (
paracross "github.com/33cn/plugin/plugin/dapp/paracross/types" paracross "github.com/33cn/plugin/plugin/dapp/paracross/types"
pt "github.com/33cn/plugin/plugin/dapp/paracross/types" pt "github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/herumi/bls-eth-go-binary/bls" "github.com/herumi/bls-eth-go-binary/bls"
"github.com/pkg/errors"
) )
const ( const (
...@@ -354,43 +353,6 @@ func (client *client) ProcEvent(msg *queue.Message) bool { ...@@ -354,43 +353,6 @@ func (client *client) ProcEvent(msg *queue.Message) bool {
return false return false
} }
func (client *client) sendP2PMsg(ty int64, data interface{}) ([]byte, error) {
msg := client.GetQueueClient().NewMessage("p2p", ty, data)
err := client.GetQueueClient().Send(msg, true)
if err != nil {
return nil, errors.Wrapf(err, "ty=%d", ty)
}
resp, err := client.GetQueueClient().Wait(msg)
if err != nil {
return nil, errors.Wrapf(err, "wait ty=%d", ty)
}
if resp.GetData().(*types.Reply).IsOk {
return resp.GetData().(*types.Reply).Msg, nil
}
return nil, errors.Wrapf(types.ErrInvalidParam, "resp msg=%s", string(resp.GetData().(*types.Reply).GetMsg()))
}
// p2p订阅消息
func (client *client) SendPubP2PMsg(topic string, msg []byte) error {
data := &types.PublishTopicMsg{Topic: topic, Msg: msg}
_, err := client.sendP2PMsg(types.EventPubTopicMsg, data)
return err
}
func (client *client) SendSubP2PTopic(topic string) error {
data := &types.SubTopic{Topic: topic, Module: "consensus"}
_, err := client.sendP2PMsg(types.EventSubTopic, data)
return err
}
func (client *client) SendRmvP2PTopic(topic string) error {
data := &types.RemoveTopic{Topic: topic, Module: "consensus"}
_, err := client.sendP2PMsg(types.EventRemoveTopic, data)
return err
}
func (client *client) isCaughtUp() bool { func (client *client) isCaughtUp() bool {
return atomic.LoadInt32(&client.caughtUp) == 1 return atomic.LoadInt32(&client.caughtUp) == 1
} }
......
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package para
import (
"github.com/33cn/chain33/types"
"github.com/pkg/errors"
)
//新增需要保证顺序
const (
P2pSubCommitTx = 1
P2pSubLeaderSyncMsg = 2
)
func (client *client) sendP2PMsg(ty int64, data interface{}) ([]byte, error) {
msg := client.GetQueueClient().NewMessage("p2p", ty, data)
err := client.GetQueueClient().Send(msg, true)
if err != nil {
return nil, errors.Wrapf(err, "ty=%d", ty)
}
resp, err := client.GetQueueClient().Wait(msg)
if err != nil {
return nil, errors.Wrapf(err, "wait ty=%d", ty)
}
if resp.GetData().(*types.Reply).IsOk {
return resp.GetData().(*types.Reply).Msg, nil
}
return nil, errors.Wrapf(types.ErrInvalidParam, "resp msg=%s", string(resp.GetData().(*types.Reply).GetMsg()))
}
// p2p订阅消息
func (client *client) SendPubP2PMsg(topic string, msg []byte) error {
data := &types.PublishTopicMsg{Topic: topic, Msg: msg}
_, err := client.sendP2PMsg(types.EventPubTopicMsg, data)
return err
}
func (client *client) SendSubP2PTopic(topic string) error {
data := &types.SubTopic{Topic: topic, Module: "consensus"}
_, err := client.sendP2PMsg(types.EventSubTopic, data)
return err
}
func (client *client) SendRmvP2PTopic(topic string) error {
data := &types.RemoveTopic{Topic: topic, Module: "consensus"}
_, err := client.sendP2PMsg(types.EventRemoveTopic, data)
return err
}
...@@ -30,12 +30,6 @@ const ( ...@@ -30,12 +30,6 @@ const (
paraBlsSignTopic = "PARA-BLS-SIGN-TOPIC" paraBlsSignTopic = "PARA-BLS-SIGN-TOPIC"
) )
//新增需要保证顺序
const (
P2pSubCommitTx = 1
P2pSubLeaderSyncMsg = 2
)
type blsClient struct { type blsClient struct {
paraClient *client paraClient *client
selfID string selfID string
......
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