p2pms

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0, MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DHT_RECORD_PREFIX      = "/" + DHT_NAMESPACE + "/"
	DHT_NAMESPACE          = "scaddr"
	DHT_RECORD_MAX_AGE     = 24 * time.Hour
	DHT_REPUBLISH_INTERVAL = 4 * time.Hour
)
View Source
const (
	DHT_PROTOCOL_PREFIX     protocol.ID = "/nitro" // use /nitro/kad/1.0.0 instead of /ipfs/kad/1.0.0
	GENERAL_MSG_PROTOCOL_ID protocol.ID = "/nitro/msg/1.0.0"

	DELIMITER                = '\n'
	BUFFER_SIZE              = 1_000
	NUM_CONNECT_ATTEMPTS     = 10
	RETRY_SLEEP_DURATION     = 5 * time.Second
	BOOTSTRAP_SLEEP_DURATION = 100 * time.Millisecond // how often we check for bootpeers in Peerstore
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageOpts added in v0.1.2

type MessageOpts struct {
	PkBytes   []byte
	Port      int
	BootPeers []string
	PublicIp  string
	SCAddr    types.Address
}

type P2PMessageService

type P2PMessageService struct {
	MultiAddr string
	// contains filtered or unexported fields
}

P2PMessageService is a rudimentary message service that uses TCP to send and receive messages.

func NewMessageService

func NewMessageService(opts MessageOpts) *P2PMessageService

NewMessageService returns a running P2PMessageService listening on the given ip, port and message key.

func (*P2PMessageService) Close

func (ms *P2PMessageService) Close() error

Close closes the P2PMessageService

func (*P2PMessageService) Id

func (ms *P2PMessageService) Id() peer.ID

Id returns the libp2p peer ID of the message service.

func (*P2PMessageService) InitComplete

func (ms *P2PMessageService) InitComplete() <-chan struct{}

InitComplete returns a chan that gets closed once the message service is initalized

func (*P2PMessageService) Out

func (ms *P2PMessageService) Out() <-chan protocols.Message

Out returns a channel that can be used to receive messages from the message service

func (*P2PMessageService) PeerInfoReceived

func (ms *P2PMessageService) PeerInfoReceived() <-chan basicPeerInfo

PeerInfoReceived returns a channel that receives a PeerInfo when a peer is discovered

func (*P2PMessageService) Send

func (ms *P2PMessageService) Send(msg protocols.Message) error

Send sends messages to other participants. It blocks until the message is sent. It will retry establishing a stream NUM_CONNECT_ATTEMPTS times before giving up

Jump to

Keyboard shortcuts

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