p2p

package
v0.0.0-...-a163439 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgProposal        = 0x01
	MsgVote            = 0x02
	MsgVerifiedBlock   = 0x03
	MsgHelloRequest    = 0x04
	MsgHelloResponse   = 0x05
	TopicHello         = "/mpbft/dev/hello/1.0.0"
	TopicFullBlock     = "/mpbft/dev/fullblock/1.0.0"
	TopicConsensusSync = "/mpbft/dev/consensus_sync/1.0.0"
)

Variables

View Source
var TestMode bool

Functions

func ReadMsgWithPrependedSize

func ReadMsgWithPrependedSize(stream stream.Stream) ([]byte, error)

func RunDevp2p

func RunDevp2p(
	state *consensus.ConsensusState,
	obsvC chan consensus.MsgInfo,
	sendC chan consensus.Message,
	priv crypto.PrivKey,
	port uint,
	networkID string,
	bootstrapPeers string,
	nodeName string,
	rootCtxCancel context.CancelFunc) func(ctx context.Context) error

func Send

func Send(ctx context.Context, h host.Host, peer peer.ID, topic string, msg interface{}) (stream.Stream, error)

func SendRPC

func SendRPC(ctx context.Context, h host.Host, peer peer.ID, topic string, req interface{}, resp interface{}) error

func SplitAndTrim

func SplitAndTrim(input string) (ret []string)

SplitAndTrim splits input separated by a comma and trims excessive white space from the substrings.

func WriteMsgWithPrependedSize

func WriteMsgWithPrependedSize(stream network.Stream, msg []byte) error

Types

type BlockSync

type BlockSync struct {
	// contains filtered or unexported fields
}

func NewBlockSync

func NewBlockSync(h host.Host, chainState consensus.ChainState, blockStore consensus.BlockStore, executor consensus.BlockExecutor, obsvC chan consensus.MsgInfo) *BlockSync

func (*BlockSync) LastChainState

func (bs *BlockSync) LastChainState() consensus.ChainState

func (*BlockSync) Start

func (bs *BlockSync) Start(ctx context.Context)

func (*BlockSync) WaitDone

func (bs *BlockSync) WaitDone() error

type GetFullBlockRequest

type GetFullBlockRequest struct {
	Height uint64
}

type GetLatestMessagesRequest

type GetLatestMessagesRequest struct {
}

type GetLatestMessagesResponse

type GetLatestMessagesResponse struct {
	MessageData [][]byte
}

type HelloRequest

type HelloRequest struct {
	LastHeight uint64
}

func (*HelloRequest) ValidateBasic

func (req *HelloRequest) ValidateBasic() error

type HelloResponse

type HelloResponse struct {
	LastHeight uint64
}

func (*HelloResponse) ValidateBasic

func (req *HelloResponse) ValidateBasic() error

type PeerHandler

type PeerHandler struct {
	// contains filtered or unexported fields
}

type Server

type Server struct {
	Host host.Host
	// contains filtered or unexported fields
}

func NewP2PServer

func NewP2PServer(
	ctx context.Context,
	blockStore consensus.BlockStore,
	obsvC chan consensus.MsgInfo,
	sendC chan consensus.Message,
	priv crypto.PrivKey,
	port uint,
	networkID string,
	bootstrapPeers string,
	nodeName string,
	rootCtxCancel context.CancelFunc,
) (*Server, error)

func (*Server) Run

func (server *Server) Run(ctx context.Context) error

func (*Server) SetConsensusState

func (server *Server) SetConsensusState(cs *consensus.ConsensusState)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL