dashboard

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebsocketCmdRegister   = 0
	WebsocketCmdUnregister = 1
)
View Source
const (
	VisualizerInitValuesCount = 3000
	VisualizerCapacity        = 3000
)
View Source
const (
	FeatureCoreAPI          = "core/v2"
	FeatureDashboardMetrics = "dashboard-metrics/v1"
	FeatureIndexer          = "indexer/v1"
	FeatureParticipation    = "participation/v1"
	FeatureSpammer          = "spammer/v1"

	BasePath              = ""
	APIBasePath           = "/api"
	CoreAPIRoute          = BasePath + "/" + FeatureCoreAPI
	DashboardMetricsRoute = APIBasePath + "/" + FeatureDashboardMetrics
	IndexerRoute          = BasePath + "/" + FeatureIndexer
	ParticipationRoute    = BasePath + "/" + FeatureParticipation
	SpammerRoute          = BasePath + "/" + FeatureSpammer
)
View Source
const (
	// ParameterBlockID is used to identify a block by its ID.
	ParameterBlockID = "blockID"

	// ParameterTransactionID is used to identify a transaction by its ID.
	ParameterTransactionID = "transactionID"

	// ParameterOutputID is used to identify an output by its ID.
	ParameterOutputID = "outputID"

	// ParameterMilestoneIndex is used to identify a milestone by index.
	ParameterMilestoneIndex = "milestoneIndex"

	// ParameterMilestoneID is used to identify a milestone by its ID.
	ParameterMilestoneID = "milestoneID"

	// ParameterPeerID is used to identify a peer.
	ParameterPeerID = "peerID"

	// RouteRoutes is the route for getting the routes the node exposes.
	// GET returns the routes.
	RouteRoutes = BasePath + "/routes"

	// RouteCoreInfo is the route for getting the node info.
	// GET returns the node info.
	RouteCoreInfo = CoreAPIRoute + "/info"

	// RouteCoreBlock is the route for getting a block by its blockID.
	// GET returns the block based on the given type in the request "Accept" header.
	// MIMEApplicationJSON => json
	// MIMEVendorIOTASerializer => bytes.
	RouteCoreBlock = CoreAPIRoute + "/blocks/:" + ParameterBlockID

	// RouteCoreBlockMetadata is the route for getting block metadata by its blockID.
	// GET returns block metadata (including info about "promotion/reattachment needed").
	RouteCoreBlockMetadata = CoreAPIRoute + "/blocks/:" + ParameterBlockID + "/metadata"

	// RouteCoreTransactionsIncludedBlock is the route for getting the block that was included in the ledger for a given transaction ID.
	// GET returns the block based on the given type in the request "Accept" header.
	// MIMEApplicationJSON => json
	// MIMEVendorIOTASerializer => bytes.
	RouteCoreTransactionsIncludedBlock = CoreAPIRoute + "/transactions/:" + ParameterTransactionID + "/included-block"

	// RouteCoreMilestoneByID is the route for getting a milestone by its ID.
	// GET returns the milestone.
	// MIMEApplicationJSON => json
	// MIMEVendorIOTASerializer => bytes.
	RouteCoreMilestoneByID = CoreAPIRoute + "/milestones/:" + ParameterMilestoneID

	// RouteCoreMilestoneByIndex is the route for getting a milestone by its milestoneIndex.
	// GET returns the milestone.
	// MIMEApplicationJSON => json
	// MIMEVendorIOTASerializer => bytes.
	RouteCoreMilestoneByIndex = CoreAPIRoute + "/milestones/by-index/:" + ParameterMilestoneIndex

	// RouteCoreOutput is the route for getting an output by its outputID (transactionHash + outputIndex).
	// GET returns the output based on the given type in the request "Accept" header.
	// MIMEApplicationJSON => json
	// MIMEVendorIOTASerializer => bytes.
	RouteCoreOutput = CoreAPIRoute + "/outputs/:" + ParameterOutputID

	// RouteCorePeer is the route for getting peers by their peerID.
	// GET returns the peer
	// DELETE deletes the peer.
	RouteCorePeer = CoreAPIRoute + "/peers/:" + ParameterPeerID

	// RouteCorePeers is the route for getting all peers of the node.
	// GET returns a list of all peers.
	// POST adds a new peer.
	RouteCorePeers = CoreAPIRoute + "/peers"
)
View Source
const (
	// ParameterFoundryID is used to identify a foundry by its ID.
	ParameterFoundryID = "foundryID"

	// ParameterAliasID is used to identify an alias by its ID.
	ParameterAliasID = "aliasID"

	// ParameterNFTID is used to identify a nft by its ID.
	ParameterNFTID = "nftID"

	// RouteIndexerOutputsBasic is the route for getting basic outputs filtered by the given parameters.
	// GET with query parameter returns all outputIDs that fit these filter criteria.
	// Query parameters: "address", "hasStorageReturnCondition", "storageReturnAddress", "hasExpirationCondition",
	//					 "expiresBefore", "expiresAfter", "expiresBeforeMilestone", "expiresAfterMilestone",
	//					 "hasTimelockCondition", "timelockedBefore", "timelockedAfter", "timelockedBeforeMilestone",
	//					 "timelockedAfterMilestone", "sender", "tag", "createdBefore", "createdAfter"
	// Returns an empty list if no results are found.
	RouteIndexerOutputsBasic = IndexerRoute + "/outputs/basic"

	// RouteIndexerOutputsAliases is the route for getting aliases filtered by the given parameters.
	// GET with query parameter returns all outputIDs that fit these filter criteria.
	// Query parameters: "stateController", "governor", "issuer", "sender", "createdBefore", "createdAfter"
	// Returns an empty list if no results are found.
	RouteIndexerOutputsAliases = IndexerRoute + "/outputs/alias"

	// RouteIndexerOutputsAliasByID is the route for getting aliases by their aliasID.
	// GET returns the outputIDs or 404 if no record is found.
	RouteIndexerOutputsAliasByID = IndexerRoute + "/outputs/alias/:" + ParameterAliasID

	// RouteIndexerOutputsNFTs is the route for getting NFT filtered by the given parameters.
	// Query parameters: "address", "hasStorageReturnCondition", "storageReturnAddress", "hasExpirationCondition",
	//					 "expiresBefore", "expiresAfter", "expiresBeforeMilestone", "expiresAfterMilestone",
	//					 "hasTimelockCondition", "timelockedBefore", "timelockedAfter", "timelockedBeforeMilestone",
	//					 "timelockedAfterMilestone", "issuer", "sender", "tag", "createdBefore", "createdAfter"
	// Returns an empty list if no results are found.
	RouteIndexerOutputsNFTs = IndexerRoute + "/outputs/nft"

	// RouteIndexerOutputsNFTByID is the route for getting NFT by their nftID.
	// GET returns the outputIDs or 404 if no record is found.
	RouteIndexerOutputsNFTByID = IndexerRoute + "/outputs/nft/:" + ParameterNFTID

	// RouteIndexerOutputsFoundries is the route for getting foundries filtered by the given parameters.
	// GET with query parameter returns all outputIDs that fit these filter criteria.
	// Query parameters: "aliasAddress", "createdBefore", "createdAfter"
	// Returns an empty list if no results are found.
	RouteIndexerOutputsFoundries = IndexerRoute + "/outputs/foundry"

	// RouteIndexerOutputsFoundryByID is the route for getting foundries by their foundryID.
	// GET returns the outputIDs or 404 if no record is found.
	RouteIndexerOutputsFoundryByID = IndexerRoute + "/outputs/foundry/:" + ParameterFoundryID
)
View Source
const (
	// RouteDashboardNodeInfoExtended is the route to get additional info about the node.
	// GET returns the extended info of the node.
	RouteDashboardNodeInfoExtended = DashboardMetricsRoute + "/info"

	// RouteDashboardDatabaseSizes is the route to get the size of the databases.
	// GET returns the sizes of the databases.
	RouteDashboardDatabaseSizes = DashboardMetricsRoute + "/database/sizes"

	// RouteDashboardGossipMetrics is the route to get metrics about gossip.
	// GET returns the gossip metrics.
	RouteDashboardGossipMetrics = DashboardMetricsRoute + "/gossip"
)
View Source
const (
	// ParameterParticipationEventID is used to identify an event by its ID.
	ParameterParticipationEventID = "eventID"

	// RouteParticipationEvents is the route to list all events, returning their ID, the event name and status.
	// GET returns a list of all events known to the node. Optional query parameter returns filters events by type (query parameters: "type").
	RouteParticipationEvents = ParticipationRoute + "/events"

	// RouteParticipationEvent is the route to access a single participation by its ID.
	// GET gives a quick overview of the participation. This does not include the current standings.
	RouteParticipationEvent = ParticipationRoute + "/events/:" + ParameterParticipationEventID

	// RouteParticipationEventStatus is the route to access the status of a single participation by its ID.
	// GET returns the amount of tokens participating and accumulated votes for the ballot if the event contains a ballot. Optional query parameter returns the status for the given milestone index (query parameters: "milestoneIndex").
	RouteParticipationEventStatus = ParticipationRoute + "/events/:" + ParameterParticipationEventID + "/status"

	// RouteParticipationAdminCreateEvent is the route the node operator can use to add events.
	// POST creates a new event to track.
	RouteParticipationAdminCreateEvent = ParticipationRoute + "/admin/events"

	// RouteParticipationAdminDeleteEvent is the route the node operator can use to remove events.
	// DELETE removes a tracked participation.
	RouteParticipationAdminDeleteEvent = ParticipationRoute + "/admin/events/:" + ParameterParticipationEventID
)
View Source
const (
	// RouteSpammerStatus is the route to get the status of the spammer.
	// GET the current status of the spammer.
	RouteSpammerStatus = SpammerRoute + "/status"

	// RouteSpammerStart is the route to start the spammer (with optional changing the settings).
	// POST the settings to change and start the spammer.
	RouteSpammerStart = SpammerRoute + "/start"

	// RouteSpammerStop is the route to stop the spammer.
	// POST to stop the spammer.
	RouteSpammerStop = SpammerRoute + "/stop"
)
View Source
const (
	VisualizerIDLength = 10
)

Variables

This section is empty.

Functions

func WithAuthIdentityFilePath added in v1.0.0

func WithAuthIdentityFilePath(authIdentityFilePath string) options.Option[Dashboard]

func WithAuthIdentityPrivateKey added in v1.0.0

func WithAuthIdentityPrivateKey(authIdentityPrivateKey string) options.Option[Dashboard]

func WithAuthPasswordHash added in v1.0.0

func WithAuthPasswordHash(authPasswordHash string) options.Option[Dashboard]

func WithAuthPasswordSalt added in v1.0.0

func WithAuthPasswordSalt(authPasswordSalt string) options.Option[Dashboard]

func WithAuthRateLimitEnabled added in v1.0.0

func WithAuthRateLimitEnabled(authRateLimitEnabled bool) options.Option[Dashboard]

func WithAuthRateLimitMaxBurst added in v1.0.0

func WithAuthRateLimitMaxBurst(authRateLimitMaxBurst int) options.Option[Dashboard]

func WithAuthRateLimitMaxRequests added in v1.0.0

func WithAuthRateLimitMaxRequests(authRateLimitMaxRequests int) options.Option[Dashboard]

func WithAuthRateLimitPeriod added in v1.0.0

func WithAuthRateLimitPeriod(authRateLimitPeriod time.Duration) options.Option[Dashboard]

func WithAuthSessionTimeout added in v1.0.0

func WithAuthSessionTimeout(authSessionTimeout time.Duration) options.Option[Dashboard]

func WithAuthUsername added in v1.0.0

func WithAuthUsername(authUsername string) options.Option[Dashboard]

func WithBindAddress added in v1.0.0

func WithBindAddress(bindAddress string) options.Option[Dashboard]

func WithDebugLogRequests added in v1.0.0

func WithDebugLogRequests(debugLogRequests bool) options.Option[Dashboard]

func WithDeveloperMode added in v1.0.0

func WithDeveloperMode(developerMode bool) options.Option[Dashboard]

func WithDeveloperModeURL added in v1.0.0

func WithDeveloperModeURL(developerModeURL string) options.Option[Dashboard]

func WithWebsocketWriteTimeout added in v1.0.0

func WithWebsocketWriteTimeout(writeTimeout time.Duration) options.Option[Dashboard]

Types

type BlockMetadata

type BlockMetadata struct {
	BlockID        iotago.BlockID
	Parents        iotago.BlockIDs
	IsSolid        bool
	IsReferenced   bool
	IsConflicting  bool
	ShouldPromote  bool
	ShouldReattach bool
}

type Dashboard

type Dashboard struct {
	// the logger used to log events.
	*logger.WrappedLogger
	// contains filtered or unexported fields
}

func New

func New(
	log *logger.Logger,
	daemon hivedaemon.Daemon,
	nodeBridge *nodebridge.NodeBridge,
	hub *websockethub.Hub,
	opts ...options.Option[Dashboard]) *Dashboard

func (*Dashboard) Init

func (d *Dashboard) Init()

func (*Dashboard) Run

func (d *Dashboard) Run()

type DatabaseSizesMetric

type DatabaseSizesMetric struct {
	Tangle int64 `json:"tangle"`
	UTXO   int64 `json:"utxo"`
	Total  int64 `json:"total"`
	Time   int64 `json:"ts"`
}

DatabaseSizesMetric represents database size metrics.

type GossipMetrics

type GossipMetrics struct {
	Incoming uint32 `json:"incoming"`
	New      uint32 `json:"new"`
	Outgoing uint32 `json:"outgoing"`
}

GossipMetrics represents a websocket message.

type MetricsClient

type MetricsClient struct {
	*nodeclient.Client
}

MetricsClient is an API wrapper over the dashboard metrics node API.

func NewMetricsClient

func NewMetricsClient(client *nodeclient.Client) *MetricsClient

NewMetricsClient returns a new dashboard metrics node API instance.

func (*MetricsClient) DatabaseSizes

func (client *MetricsClient) DatabaseSizes(ctx context.Context) (*DatabaseSizesMetric, error)

func (*MetricsClient) GossipMetrics

func (client *MetricsClient) GossipMetrics(ctx context.Context) (*GossipMetrics, error)

func (*MetricsClient) NodeInfoExtended

func (client *MetricsClient) NodeInfoExtended(ctx context.Context) (*NodeInfoExtended, error)

type Milestone

type Milestone struct {
	MilestoneID string `json:"milestoneId"`
	Index       uint32 `json:"index"`
}

Milestone represents a milestone for the livefeed.

type Msg

type Msg struct {
	Type WebSocketMsgType `json:"type"`
	Data interface{}      `json:"data"`
}

Msg represents a websocket message.

type NodeInfoExtended

type NodeInfoExtended struct {
	Version       string `json:"version"`
	LatestVersion string `json:"latestVersion"`
	Uptime        int64  `json:"uptime"`
	NodeID        string `json:"nodeId"`
	NodeAlias     string `json:"nodeAlias"`
	MemoryUsage   int64  `json:"memUsage"`
}

NodeInfoExtended represents extended information about the node.

type PublicNodeStatus

type PublicNodeStatus struct {
	PruningIndex uint32 `json:"pruningIndex"`
	IsHealthy    bool   `json:"isHealthy"`
	IsSynced     bool   `json:"isSynced"`
}

PublicNodeStatus represents the public node status.

type SyncStatus

type SyncStatus struct {
	CMI uint32 `json:"cmi"`
	LMI uint32 `json:"lmi"`
}

SyncStatus represents the node sync status.

type Visualizer

type Visualizer struct {
	sync.RWMutex

	// the logger used to log events.
	*logger.WrappedLogger

	Events *VisualizerEvents
	// contains filtered or unexported fields
}

func NewVisualizer

func NewVisualizer(log *logger.Logger, nodeBridge *nodebridge.NodeBridge, capacity int) *Visualizer

func (*Visualizer) AddConfirmation

func (v *Visualizer) AddConfirmation(parents iotago.BlockIDs, conflictingBlocks iotago.BlockIDs)

func (*Visualizer) AddVertex

func (v *Visualizer) AddVertex(block *iotago.Block)

func (*Visualizer) ApplyConfirmedMilestoneChanged added in v1.0.0

func (v *Visualizer) ApplyConfirmedMilestoneChanged(ms *nodebridge.Milestone)

func (*Visualizer) ForEachCreated

func (v *Visualizer) ForEachCreated(consumer func(vertex *VisualizerVertex) bool, elementsCount ...int)

func (*Visualizer) Run added in v1.0.0

func (v *Visualizer) Run(ctx context.Context)

func (*Visualizer) SetIsConflicting

func (v *Visualizer) SetIsConflicting(blockID iotago.BlockID)

func (*Visualizer) SetIsReferenced

func (v *Visualizer) SetIsReferenced(blockID iotago.BlockID)

func (*Visualizer) SetIsSolid

func (v *Visualizer) SetIsSolid(blockID iotago.BlockID)

func (*Visualizer) UpdateState added in v1.0.0

func (v *Visualizer) UpdateState(active bool)

type VisualizerConfirmationInfo

type VisualizerConfirmationInfo struct {
	IDs         []string `json:"ids"`
	ExcludedIDs []string `json:"excludedIds"`
}

VisualizerConfirmationInfo signals confirmation of a milestone block with a list of exluded blocks in the past cone.

type VisualizerEvents

type VisualizerEvents struct {
	VertexCreated      *event.Event1[*VisualizerVertex]
	VertexSolidUpdated *event.Event1[*VisualizerVertex]
	VertexTipUpdated   *event.Event1[*VisualizerVertex]
	// params: milestoneParents []string, excludedIDs []string
	Confirmation *event.Event2[[]string, []string]
}

type VisualizerMetaInfo

type VisualizerMetaInfo struct {
	ID string `json:"id"`
}

VisualizerMetaInfo signals that metadata of a given block changed.

type VisualizerTipInfo

type VisualizerTipInfo struct {
	ID    string `json:"id"`
	IsTip bool   `json:"isTip"`
}

tipinfo holds information about whether a given block is a tip or not.

type VisualizerVertex

type VisualizerVertex struct {
	ID            string   `json:"id"`
	Parents       []string `json:"parents"`
	IsSolid       bool     `json:"isSolid"`
	IsReferenced  bool     `json:"isReferenced"`
	IsConflicting bool     `json:"isConflicting"`
	IsTransaction bool     `json:"isTransaction"`
	IsMilestone   bool     `json:"isMilestone"`
	IsTip         bool     `json:"isTip"`
	// contains filtered or unexported fields
}

VisualizerVertex defines a vertex in a DAG.

type WebSocketMsgType added in v1.0.0

type WebSocketMsgType byte
const (
	// MsgTypeSyncStatus is the type of the SyncStatus message.
	MsgTypeSyncStatus WebSocketMsgType = iota
	// MsgTypePublicNodeStatus is the type of the PublicNodeStatus message.
	MsgTypePublicNodeStatus
	// MsgTypeNodeInfoExtended is the type of the NodeInfoExtended message.
	MsgTypeNodeInfoExtended
	// MsgTypeGossipMetrics is the type of the GossipMetrics message.
	MsgTypeGossipMetrics
	// MsgTypeMilestone is the type of the Milestone message.
	MsgTypeMilestone
	// MsgTypePeerMetric is the type of the PeerMetric message.
	MsgTypePeerMetric
	// MsgTypeConfirmedMsMetrics is the type of the ConfirmedMsMetrics message.
	MsgTypeConfirmedMsMetrics
	// MsgTypeVisualizerVertex is the type of the Vertex message for the visualizer.
	MsgTypeVisualizerVertex
	// MsgTypeVisualizerSolidInfo is the type of the SolidInfo message for the visualizer.
	MsgTypeVisualizerSolidInfo
	// MsgTypeVisualizerConfirmedInfo is the type of the ConfirmedInfo message for the visualizer.
	MsgTypeVisualizerConfirmedInfo
	// MsgTypeVisualizerMilestoneInfo is the type of the MilestoneInfo message for the visualizer.
	MsgTypeVisualizerMilestoneInfo
	// MsgTypeVisualizerTipInfo is the type of the TipInfo message for the visualizer.
	MsgTypeVisualizerTipInfo
	// MsgTypeDatabaseSizeMetric is the type of the database Size message for the metrics.
	MsgTypeDatabaseSizeMetric
)

Jump to

Keyboard shortcuts

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