common

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: ISC Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FastSum256

func FastSum256(data []byte) [32]byte

FastSum256 returns a hash sum of the input data using highwayhash. This method is not secure, but may be used as a quick identifier for objects where collisions are acceptable.

func FastSum64

func FastSum64(data []byte) uint64

FastSum64 returns a hash sum of the input data using highwayhash. This method is not secure, but may be used as a quick identifier for objects where collisions are acceptable.

Types

type Config

type Config struct {
	NoDiscovery          bool
	EnableUPnP           bool
	StaticPeers          []string
	BootstrapNodeAddr    []string
	Discv5BootStrapAddr  []string
	DataDir              string
	MaxPeers             uint
	MaxInbound           int
	MetaDataDir          string
	ReadWritePermissions os.FileMode
	AllowListCIDR        string
	DenyListCIDR         []string
	TCPPort              uint
	UDPPort              uint
	EnableNoise          bool
	RelayNodeAddr        string
	LocalIP              string
	HostAddress          string
	HostDNS              string
	PrivateKey           string
	Encoding             string
	// ProtocolVersion specifies the maximum protocol version to use and
	// advertise.
	ProtocolVersion uint32
	Services        protocol.ServiceFlag
	UserAgent       string
	// DisableRelayTx specifies if the remote peer should be informed to
	// not send inv messages for transactions.
	DisableRelayTx bool
	MaxOrphanTxs   int
	Params         *params.Params
	Banning        bool // Open or not ban module
	DisableListen  bool
	LANPeers       []string
	IsCircuit      bool
}

Config for the p2p service. to initialize the p2p service.

type Error

type Error struct {
	Code  ErrorCode
	Error error
}

func NewError

func NewError(code ErrorCode, e error) *Error

type ErrorCode

type ErrorCode int

ErrorCode identifies a kind of error.

const (
	// There are no errors by default
	ErrNone ErrorCode = iota

	// p2p stream write error
	ErrStreamWrite

	// p2p stream read error
	ErrStreamRead

	// p2p stream base error
	ErrStreamBase

	// p2p peer unknown error
	ErrPeerUnknown

	// p2p peer bad error
	ErrBadPeer

	// p2p DAG consensus error
	ErrDAGConsensus

	// p2p message error
	ErrMessage
)

func (ErrorCode) IsSuccess

func (e ErrorCode) IsSuccess() bool

func (ErrorCode) String

func (e ErrorCode) String() string

type P2P

type P2P interface {
	GetGenesisHash() *hash.Hash
	BlockChain() *blockchain.BlockChain
	Host() host.Host
	Disconnect(pid peer.ID) error
	Context() context.Context
	Encoding() encoder.NetworkEncoding
	Config() *Config
	TxMemPool() *mempool.TxPool
	Metadata() *pb.MetaData
	MetadataSeq() uint64
	TimeSource() blockchain.MedianTimeSource
	Notify() notify.Notify
	ConnectTo(node *qnode.Node)
	Resolve(n *qnode.Node) *qnode.Node
	Node() *qnode.Node
	RelayNodeInfo() *peer.AddrInfo
	IncreaseBytesSent(pid peer.ID, size int)
	IncreaseBytesRecv(pid peer.ID, size int)
}

type P2PRPC

type P2PRPC interface {
	Host() host.Host
	Context() context.Context
	Encoding() encoder.NetworkEncoding
	Disconnect(pid peer.ID) error
	IncreaseBytesSent(pid peer.ID, size int)
	IncreaseBytesRecv(pid peer.ID, size int)
}

type QMultiaddr

type QMultiaddr interface {
	iaddr.IPFSAddr
}

func QMultiAddrFromString

func QMultiAddrFromString(address string) (QMultiaddr, error)

Jump to

Keyboard shortcuts

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