visualisation

package
v1.0.0-release Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHandler

func CreateHandler(upgrader websocket.Upgrader, data *[]Data, blockchain *[]Block, clientsMutex *sync.Mutex,
	clients map[*websocket.Conn]bool, log *ipfsLog.ZapEventLogger) http.HandlerFunc

CreateHandler returns an http.HandlerFunc that upgrades the HTTP connection to a WebSocket connection and handles incoming WebSocket connections. It takes an `upgrader` of type `websocket.Upgrader` to upgrade the connection, a slice of `Data` for storing data, a `clientsMutex` of type `*sync.Mutex` to synchronize access to the `clients` map, a `clients` map of type `map[*websocket.Conn]bool` to store connected clients, and a `log` of type `*ipfsLog.ZapEventLogger` for logging events.

The returned http.HandlerFunc upgrades the connection to a WebSocket connection and calls the `handleConnections` function to handle incoming WebSocket connections.

func GetPeersSubscribedToTopicForPeer

func GetPeersSubscribedToTopicForPeer(peer Data, topic string) []string

func SendDataToClients

func SendDataToClients(clientsMutex *sync.Mutex, clients map[*websocket.Conn]bool,
	message WebSocketMessage, log *ipfsLog.ZapEventLogger)

SendDataToClients sends the given WebSocketMessage to all connected clients. It takes a clientsMutex to synchronize access to the clients map, a clients map that stores the connected clients, a message of type WebSocketMessage to be sent, and a log of type *ipfsLog.ZapEventLogger for logging errors. It iterates over the clients map and sends the message to each client using WriteJSON. If there is an error while sending the message, the client is closed and removed from the clients map.

Types

type Block

type Block struct {
	Hash []byte `json:"hash"`
	block.Block
}

func NewBlock

func NewBlock(b block.Block) Block

type Data

type Data struct {
	PeerID                   string   `json:"peerID"`
	NodeType                 string   `json:"nodeType"`
	ConnectedPeers           []string `json:"connectedPeers"` // List of peers connected (peers ID) to this peer
	TopicsList               []string `json:"topicsList"`
	KeepRelayConnectionAlive []string `json:"keepRelayConnectionAlive"` // List of peers subscribed to KeepRelayConnectionAlive which are connected to this peer
	BlockAnnouncement        []string `json:"blockAnnouncement"`        // List of peers subscribed to BlockAnnouncement which are connected to this peer
	AskingBlockchain         []string `json:"askingBlockchain"`         // List of peers subscribed to AskingBlockchain which are connected to this peer
	ReceiveBlockchain        []string `json:"receiveBlockchain"`        // List of peers subscribed to ReceiveBlockchain which are connected to this peer
	ClientAnnouncement       []string `json:"clientAnnouncement"`       // List of peers subscribed to ClientAnnouncement which are connected to this peer
	StorageNodeResponse      []string `json:"storageNodeResponse"`      // List of peers subscribed to StorageNodeResponse which are connected to this peer
	FullNodeAnnouncement     []string `json:"fullNodeAnnouncement"`     // List of peers subscribed to FullNodeAnnouncement which are connected to this peer
	AskMyFilesList           []string `json:"askMyFilesList"`           // List of peers subscribed to AskMyFilesList which are connected to this peer
	ReceiveMyFilesList       []string `json:"receiveMyFilesList"`       // List of peers subscribed to ReceiveMyFilesList which are connected to this peer
}

func FindAddedNodes

func FindAddedNodes(oldData, newData []Data) []Data

func FindRemovedNodes

func FindRemovedNodes(oldData, newData []Data) []Data

func FindUpdatedNodes

func FindUpdatedNodes(oldData, newData []Data) []Data

type DiffData

type DiffData struct {
	Added   []Data `json:"added"`   // Nodes that were added
	Removed []Data `json:"removed"` // Nodes that were removed
	Updated []Data `json:"updated"` // Nodes that were updated
}

func NewDiffData

func NewDiffData(oldData, newData []Data) DiffData

type PeeringConnection

type PeeringConnection struct {
	Source string `json:"source"`
	Target string `json:"target"`
}

func GetPeersSubscribedToTopic

func GetPeersSubscribedToTopic(topic string, data []Data) ([]string, []PeeringConnection)

type PubsubMessageSignal

type PubsubMessageSignal struct {
	ID           string              `json:"id"`
	From         string              `json:"from"`
	Topic        string              `json:"topic"`
	Subscribers  []string            `json:"subscribers"`
	Connections  []PeeringConnection `json:"connections"`
	VisitedNodes []string            `json:"visitedNodes"`
}

type WebSocketMessage

type WebSocketMessage struct {
	Type string      `json:"type"` // Type specifies the type of the message.
	Data interface{} `json:"data"` // Data contains the payload of the message.
}

WebSocketMessage represents a message sent over a WebSocket connection.

Jump to

Keyboard shortcuts

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