func NewChannel(
	id ChannelID,
	messageType proto.Message,
	inCh <-chan Envelope,
	outCh chan<- Envelope,
	errCh chan<- PeerError,
) *Channel {
	return &Channel{
		ID:          id,
		messageType: messageType,
		In:          inCh,
		Out:         outCh,
		Error:       errCh,
		closeCh:     make(chan struct{}),
	}
}
NewChannel creates a new channel. It is primarily for internal and test
use, reactors should use Router.OpenChannel().
package p2p
import (
	"context"
	"errors"
	"fmt"
	"io"
	"math/rand"
	"net"
	"runtime"
	"sync"
	"time"
	"github.com/gogo/protobuf/proto"
	"github.com/tendermint/tendermint/crypto"
	"github.com/tendermint/tendermint/libs/log"
	"github.com/tendermint/tendermint/libs/service"
	"github.com/tendermint/tendermint/types"
)
const queueBufferDefault = 32
const dialRandomizerIntervalMillisecond = 3000
type Envelope struct {
	From      types.NodeID   
	To        types.NodeID   
	Broadcast bool           
	Message   proto.Message  
	channelID ChannelID
}
type PeerError struct {
	NodeID types.NodeID
	Err    error
}
type Channel struct {
	ID    ChannelID
	In    <-chan Envelope   
	Out   chan<- Envelope   
	Error chan<- PeerError  
	messageType proto.Message  
	closeCh     chan struct{}
	closeOnce   sync.Once
}