mj

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: BlueOak-1.0.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNone = iota
	ErrTimeout
	ErrInternal
	ErrBadRequest
	ErrAuth
	ErrSig
	ErrNoConfig
	ErrBannned
	ErrFailedRelay
)
View Source
const (
	// tatanka <=> tatanka
	RouteTatankaConfig    = "tatanka_config"
	RouteTatankaConnect   = "tatanka_connect"
	RouteNewClient        = "new_client"
	RouteClientDisconnect = "client_disconnect"
	RouteGetReputation    = "get_reputation"
	RouteRelayBroadcast   = "relay_broadcast"
	RouteRelayTankagram   = "relay_tankagram"
	RoutePathInquiry      = "path_inquiry"

	// tatanka <=> client
	RouteConnect     = "connect"
	RouteConfig      = "config"
	RoutePostBond    = "post_bond"
	RouteSubscribe   = "subscribe"
	RouteUnsubscribe = "unsubscribe"
	RouteRates       = "rates"

	// client1 <=> tatankanode <=> client2
	RouteTankagram     = "tankagram"
	RouteEncryptionKey = "encryption_key"
	RouteBroadcast     = "broadcast"
	RouteNewSubscriber = "new_subscriber"
)
View Source
const (
	TopicMarket   = "market"
	TopicFiatRate = "fiat_rate"
)

Variables

This section is empty.

Functions

func CheckSig

func CheckSig(msg *msgjson.Message, pubKey *secp256k1.PublicKey) error

CheckSig checks that the message's signature was created with the private key for the provided secp256k1 public key on the sha256 hash of the message.

func MessageDigest

func MessageDigest(msg *msgjson.Message) [32]byte

func MustNotification

func MustNotification(route string, payload any) *msgjson.Message

func MustRequest

func MustRequest(route string, payload any) *msgjson.Message

func MustResponse

func MustResponse(id uint64, payload any, rpcErr *msgjson.Error) *msgjson.Message

func NewMessageID

func NewMessageID() uint64

func SignMessage

func SignMessage(priv *secp256k1.PrivateKey, msg *msgjson.Message)

func Truncate

func Truncate(b []byte) string

Types

type Broadcast

type Broadcast struct {
	PeerID      tanka.PeerID         `json:"peerID"`
	Topic       tanka.Topic          `json:"topic"`
	Subject     tanka.Subject        `json:"subject"`
	MessageType BroadcastMessageType `json:"messageType"`
	Payload     dex.Bytes            `json:"payload,omitempty"`
	Stamp       time.Time            `json:"stamp"`
}

type BroadcastMessageType

type BroadcastMessageType string
const (
	MessageTypeTrollBox      BroadcastMessageType = "troll_box"
	MessageTypeNewOrder      BroadcastMessageType = "new_order"
	MessageTypeProposeMatch  BroadcastMessageType = "propose_match"
	MessageTypeAcceptMatch   BroadcastMessageType = "accept_match"
	MessageTypeNewSubscriber BroadcastMessageType = "new_subscriber"
	MessageTypeUnsubTopic    BroadcastMessageType = "unsub_topic"
	MessageTypeUnsubSubject  BroadcastMessageType = "unsub_subject"
)

type Connect

type Connect struct {
	ID tanka.PeerID `json:"id"`
}

type Disconnect

type Disconnect = Connect

type FundedMessage

type FundedMessage struct {
	AssetID uint32          `json:"assetID"`
	Funding json.RawMessage `json:"funding"`
	Msg     msgjson.Message `json:"msg"`
}

type NewSubscriber

type NewSubscriber struct {
	PeerID  tanka.PeerID  `json:"peerID"`
	Topic   tanka.Topic   `json:"topic"`
	Subject tanka.Subject `json:"subject"`
}

type PathInquiry

type PathInquiry = Connect

type RateMessage

type RateMessage struct {
	Topic tanka.Topic                        `json:"topic"`
	Rates map[string]*fiatrates.FiatRateInfo `json:"rates"`
}

type RemoteReputation

type RemoteReputation struct {
	Score  int16
	NumPts uint8
}

type Subscription

type Subscription struct {
	Topic   tanka.Topic   `json:"topic"`
	Subject tanka.Subject `json:"subject"`
}

type Tankagram

type Tankagram struct {
	To           tanka.PeerID     `json:"to"`
	From         tanka.PeerID     `json:"from"`
	Message      *msgjson.Message `json:"message,omitempty"`
	EncryptedMsg dex.Bytes        `json:"encryptedMessage,omitempty"`
}

type TankagramResult

type TankagramResult struct {
	Result   TankagramResultType `json:"result"`
	Response dex.Bytes           `json:"response"`
	// If the tankagram is not transmitted, the server will stamp and sign the
	// tankagram separately.
	Stamp uint64    `json:"stamp"`
	Sig   dex.Bytes `json:"sig"`
}

func (*TankagramResult) Sign

func (r *TankagramResult) Sign(priv *secp256k1.PrivateKey)

type TankagramResultType

type TankagramResultType string

TankagramResultType is a critical component of the mesh network's reputation system. The outcome of self-reported audits of counterparty failures will depend heavily on what signed TankagramResult.Result is submitted.

const (
	TRTTransmitted  TankagramResultType = "transmitted"
	TRTNoPath       TankagramResultType = "nopath"
	TRTErrFromPeer  TankagramResultType = "errorfrompeer"
	TRTErrFromTanka TankagramResultType = "errorfromtanka"
	TRTErrBadClient TankagramResultType = "badclient"
)

type TatankaConfig

type TatankaConfig struct {
	ID      tanka.PeerID `json:"id"`
	Version uint32       `json:"version"`
	Chains  []uint32     `json:"chains"`
	// BondTier is the senders current view of the receiver's tier.
	BondTier uint64 `json:"bondTier"`
}

type Troll

type Troll struct {
	Msg string `json:"msg"`
}

type Unsubscription

type Unsubscription struct {
	Topic  tanka.Topic  `json:"topic"`
	PeerID tanka.PeerID `json:"peerID"`
}

Jump to

Keyboard shortcuts

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