pkg

package
v0.0.0-...-b7c7d3f Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicKeySize = ed25519.PublicKeySize
	SignatureSize = ed25519.SignatureSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
}

Agent is the main tft agent entity

func (*Agent) SetupAdminControl

func (a *Agent) SetupAdminControl()

SetupAdminControl for the agent, allowing it to be controlled over an http interface. WARNING: this interface has full controll over the agent, including wallets and their secrets

type BufferedNode

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

func NewBufferedNode

func NewBufferedNode(store PeerStore) *BufferedNode

NewBufferedNode creates a new buffered node embedding a regular P2PNode

func (*BufferedNode) PeerID

func (bn *BufferedNode) PeerID() string

PeerID returns the underlying nodes PeerID

func (*BufferedNode) Send

func (bn *BufferedNode) Send(message Message) error

func (*BufferedNode) Start

func (bn *BufferedNode) Start(ctx context.Context, privateKey crypto.PrivKey) error

type Log

type Log interface {
	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
}

type Message

type Message struct {
	// Sender digital twin ID
	Sender uint64 `json:"sender"`
	// Receiver digital twin ID
	Receiver uint64 `json:"receiver"`
	// Topic of the message
	Topic string `json:"topic"`
	// TTL of the message, after this time, the message should be flushed from
	// receiving and sending buffers.
	TTL time.Time `json:"ttl"`
	// Payload of the message
	Payload []byte `json:"payload"`
}

Message being sent between peers

type NOOPLogger

type NOOPLogger struct{}

func (*NOOPLogger) Debug

func (n *NOOPLogger) Debug(v ...interface{})

func (*NOOPLogger) Debugf

func (n *NOOPLogger) Debugf(v ...interface{})

func (*NOOPLogger) Error

func (n *NOOPLogger) Error(v ...interface{})

func (*NOOPLogger) Errorf

func (n *NOOPLogger) Errorf(format string, v ...interface{})

func (*NOOPLogger) Info

func (n *NOOPLogger) Info(v ...interface{})

func (*NOOPLogger) Infof

func (n *NOOPLogger) Infof(format string, v ...interface{})

func (*NOOPLogger) Warn

func (n *NOOPLogger) Warn(v ...interface{})

func (*NOOPLogger) Warnf

func (n *NOOPLogger) Warnf(format string, v ...interface{})

type P2PNode

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

P2PNode handles streams amd connections

func NewP2PNode

func NewP2PNode(msgChan chan<- Message) *P2PNode

func (*P2PNode) PeerID

func (c *P2PNode) PeerID() string

func (*P2PNode) Send

func (c *P2PNode) Send(message Message, peerID peer.ID, timeout time.Duration) error

Send sends a message to a list of addresses

func (*P2PNode) Start

func (c *P2PNode) Start(ctx context.Context, privateKey crypto.PrivKey) error

Start creates a libp2p host and starts handling connections

type PeerStore

type PeerStore interface {
	// PeerID currently associated with this digital twin
	PeerID(dtid uint64) (string, error)
	// PublicKey of this digital twin
	PublicKey(dtid uint64) ([PublicKeySize]byte, error)
	// SetPeerId of this digital twin. This should override a cached peer ID of
	// a digital twin. NOTE: because the transport does not validate keys of remote
	// digital twins, a malicous entity could emulate a peer ID and poison the peer
	// cache. As such, this should only be used in development.
	SetPeerID(dtid uint64, pid string)
}

PeerStore allows looking up info for a peer digital twin ID

type Server

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

Server accepting connections, running RESP with custom commands

func NewServer

func NewServer(ctx context.Context, port uint16, ps PeerStore, node *BufferedNode) (*Server, error)

NewServer creates a new server. This binds the given port, but does not yet accept incomming connections

func (*Server) Close

func (s *Server) Close() error

Close the server and its connections

func (*Server) Run

func (s *Server) Run() error

Run the server until the context is done, or an error is encountered while accepting the connection. A new goroutine is spawned per new connection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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