messages

package
v0.2.97 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEvenMessageType   = fmt.Errorf("message type is even")
	ErrMessageNotInRange = fmt.Errorf("message type not in range")
)

Functions

func InRange

func InRange(msgType MessageType) (bool, error)

InRange checks if the message type lays in the peerswap message range.

func MessageTypeToHexString

func MessageTypeToHexString(messageIndex MessageType) string

MessageTypeToHexStr returns the hex encoded string of the messagetype.

Types

type ErrAlreadyHasASender

type ErrAlreadyHasASender string

func (ErrAlreadyHasASender) Error

func (e ErrAlreadyHasASender) Error() string

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

func (*Manager) AddSender

func (m *Manager) AddSender(id string, messenger StoppableMessenger) error

func (*Manager) RemoveSender

func (m *Manager) RemoveSender(id string)

type Message

type Message interface{}

Message needs to have a MessageType.

type MessageType

type MessageType int
const (
	// BASE_MESSAGE_TYPE is the first message type of the
	// peerswap messages in the range of custom message
	// types according to BOLT #1. All other peerswap
	// messages add even numbers to the base type to keep
	// the message type odd.
	BASE_MESSAGE_TYPE = 42069
	// These are the peeerswap swap related messages as
	// specified by the peerswap protocol. They are
	// evenly separated to keep the resulting message type
	// odd.
	MESSAGETYPE_SWAPINREQUEST MessageType = BASE_MESSAGE_TYPE - 1 + iota

	MESSAGETYPE_SWAPOUTREQUEST

	MESSAGETYPE_SWAPINAGREEMENT

	MESSAGETYPE_SWAPOUTAGREEMENT

	MESSAGETYPE_OPENINGTXBROADCASTED

	MESSAGETYPE_CANCELED

	MESSAGETYPE_COOPCLOSE

	MESSAGETYPE_POLL

	MESSAGETYPE_REQUEST_POLL
	UPPER_MESSAGE_BOUND
)

func HexStringToMessageType

func HexStringToMessageType(msgTypeStr string) (MessageType, error)

HexStrToMsgType returns the message type from a hex encoded string.

type Messenger

type Messenger interface {
	SendMessage(peerId string, message []byte, messageType int) error
}

type RedundantMessenger

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

func NewRedundantMessenger

func NewRedundantMessenger(messenger Messenger, retryTime time.Duration) *RedundantMessenger

func (*RedundantMessenger) SendMessage

func (s *RedundantMessenger) SendMessage(peerId string, message []byte, messageType int) error

func (*RedundantMessenger) Stop

func (s *RedundantMessenger) Stop()

type StoppableMessenger

type StoppableMessenger interface {
	Messenger
	Stop()
}

Jump to

Keyboard shortcuts

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