Skip to content
Snippets Groups Projects
Unverified Commit b26c1140 authored by Luca Moser's avatar Luca Moser Committed by GitHub
Browse files

Enriches the message dashboard page with additional fields (#554)

* adds missing port to default bind address

* defer backgroundworker stop log

* terminate bootstrapper first

* fix weird background worker name

* fix msg metadata not getting released, add msg timestamp to explorer msg

* adds additional fields to the message view on the dashboard
parent 2b30696d
Branches
Tags
No related merge requests found
......@@ -155,6 +155,7 @@ func runFPC() {
if err := daemon.BackgroundWorker("FPCRoundsInitiator", func(shutdownSignal <-chan struct{}) {
log.Infof("Started FPC round initiator")
defer log.Infof("Stopped FPC round initiator")
unixTsPRNG := prng.NewUnixTimestampPRNG(roundIntervalSeconds)
unixTsPRNG.Start()
defer unixTsPRNG.Stop()
......@@ -169,7 +170,6 @@ func runFPC() {
break exit
}
}
log.Infof("Stopped FPC round initiator")
}, shutdown.PriorityFPC); err != nil {
log.Panicf("Failed to start as daemon: %s", err)
}
......
......@@ -15,6 +15,6 @@ const (
PriorityWebAPI
PriorityDashboard
PrioritySynchronization
PriorityBootstrap
PrioritySpammer
PriorityBootstrap
)
......@@ -14,8 +14,16 @@ import (
type ExplorerMessage struct {
// ID is the message ID.
ID string `json:"id"`
// Timestamp is the timestamp of the message.
Timestamp uint `json:"timestamp"`
// SolidificationTimestamp is the timestamp of the message.
SolidificationTimestamp int64 `json:"solidification_timestamp"`
// The time when this message was issued
IssuanceTimestamp int64 `json:"issuance_timestamp"`
// The issuer's sequence number of this message.
SequenceNumber uint64 `json:"sequence_number"`
// The public key of the issuer who issued this message.
IssuerPublicKey string `json:"issuer_public_key"`
// The signature of the message.
Signature string `json:"signature"`
// TrunkMessageId is the Trunk ID of the message.
TrunkMessageID string `json:"trunk_message_id"`
// BranchMessageId is the Branch ID of the message.
......@@ -30,15 +38,21 @@ type ExplorerMessage struct {
func createExplorerMessage(msg *message.Message) (*ExplorerMessage, error) {
messageID := msg.Id()
messageMetadata := messagelayer.Tangle().MessageMetadata(messageID)
cachedMessageMetadata := messagelayer.Tangle().MessageMetadata(messageID)
defer cachedMessageMetadata.Release()
messageMetadata := cachedMessageMetadata.Unwrap()
t := &ExplorerMessage{
ID: messageID.String(),
Timestamp: 0,
TrunkMessageID: msg.TrunkId().String(),
BranchMessageID: msg.BranchId().String(),
Solid: messageMetadata.Unwrap().IsSolid(),
PayloadType: msg.Payload().Type(),
Payload: ProcessPayload(msg.Payload()),
ID: messageID.String(),
SolidificationTimestamp: messageMetadata.SoldificationTime().Unix(),
IssuanceTimestamp: msg.IssuingTime().Unix(),
IssuerPublicKey: msg.IssuerPublicKey().String(),
Signature: msg.Signature().String(),
SequenceNumber: msg.SequenceNumber(),
TrunkMessageID: msg.TrunkId().String(),
BranchMessageID: msg.BranchId().String(),
Solid: cachedMessageMetadata.Unwrap().IsSolid(),
PayloadType: msg.Payload().Type(),
Payload: ProcessPayload(msg.Payload()),
}
return t, nil
......
......@@ -48,7 +48,7 @@ export class ExplorerAddressQueryResult extends React.Component<Props, any> {
msgsEle.push(
<ListGroup.Item key={msg.id}>
<small>
{dateformat(new Date(msg.timestamp * 1000), "dd.mm.yyyy HH:MM:ss")} {' '}
{dateformat(new Date(msg.solidification_timestamp * 1000), "dd.mm.yyyy HH:MM:ss")} {' '}
<Link to={`/explorer/message/${msg.id}`}>{msg.id}</Link>
</small>
</ListGroup.Item>
......
......@@ -4,7 +4,7 @@ import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import NodeStore from "app/stores/NodeStore";
import {inject, observer} from "mobx-react";
import ExplorerStore from "app/stores/ExplorerStore";
import ExplorerStore, {GenesisMessageID} from "app/stores/ExplorerStore";
import Spinner from "react-bootstrap/Spinner";
import ListGroup from "react-bootstrap/ListGroup";
import Badge from "react-bootstrap/Badge";
......@@ -35,6 +35,10 @@ export class ExplorerMessageQueryResult extends React.Component<Props, any> {
this.props.explorerStore.searchMessage(this.props.match.params.id);
}
componentWillUnmount() {
this.props.explorerStore.reset();
}
getSnapshotBeforeUpdate(prevProps: Props, prevState) {
if (prevProps.match.params.id !== this.props.match.params.id) {
this.props.explorerStore.searchMessage(this.props.match.params.id);
......@@ -43,7 +47,7 @@ export class ExplorerMessageQueryResult extends React.Component<Props, any> {
}
getPayloadType() {
switch(this.props.explorerStore.msg.payload_type) {
switch (this.props.explorerStore.msg.payload_type) {
case PayloadType.Data:
return "Data"
case PayloadType.Value:
......@@ -58,7 +62,7 @@ export class ExplorerMessageQueryResult extends React.Component<Props, any> {
}
renderPayload() {
switch(this.props.explorerStore.msg.payload_type) {
switch (this.props.explorerStore.msg.payload_type) {
case PayloadType.Drng:
return <DrngPayload/>
case PayloadType.Value:
......@@ -66,14 +70,34 @@ export class ExplorerMessageQueryResult extends React.Component<Props, any> {
case PayloadType.Data:
case PayloadType.Faucet:
default:
console.log(this.props.explorerStore.msg.payload.bytes)
return <BasicPayload/>
}
}
render() {
let {id} = this.props.match.params;
let {msg, query_loading} = this.props.explorerStore;
let {msg, query_loading, query_err} = this.props.explorerStore;
if (id === GenesisMessageID) {
return (
<Container>
<h3>Genesis Message</h3>
<p>In the beginning there was the genesis.</p>
</Container>
);
}
if (query_err) {
return (
<Container>
<h3>Message not available - 404</h3>
<p>
Message with ID {id} not found.
</p>
</Container>
);
}
return (
<Container>
<h3>Message</h3>
......@@ -84,8 +108,11 @@ export class ExplorerMessageQueryResult extends React.Component<Props, any> {
<React.Fragment>
<br/>
<span>
<Badge variant="light" style={{marginRight: 10}}>
Issuance Time: {dateformat(new Date(msg.issuance_timestamp * 1000), "dd.mm.yyyy HH:MM:ss")}
</Badge>
<Badge variant="light">
Time: {dateformat(new Date(msg.timestamp * 1000), "dd.mm.yyyy HH:MM:ss")}
Solidification Time: {dateformat(new Date(msg.solidification_timestamp * 1000), "dd.mm.yyyy HH:MM:ss")}
</Badge>
</span>
</React.Fragment>
......@@ -97,15 +124,32 @@ export class ExplorerMessageQueryResult extends React.Component<Props, any> {
<Row className={"mb-3"}>
<Col>
<ListGroup>
<ListGroup.Item>Payload Type: {this.getPayloadType()} </ListGroup.Item>
<ListGroup.Item>
Payload Type: {this.getPayloadType()}
</ListGroup.Item>
<ListGroup.Item>
Sequence Number: {msg.sequence_number}
</ListGroup.Item>
<ListGroup.Item>
Solid: {msg.solid ? 'Yes' : 'No'}
</ListGroup.Item>
</ListGroup>
</Col>
</Row>
<Row className={"mb-3"}>
<Col>
<ListGroup>
<ListGroup.Item>Solid: {msg.solid ? 'Yes' : 'No'}</ListGroup.Item>
<ListGroup.Item>
Issuer Public Key: {msg.issuer_public_key}
</ListGroup.Item>
<ListGroup.Item>
Message Signature: {msg.signature}
</ListGroup.Item>
</ListGroup>
</Col>
</Row>
<Row className={"mb-3"}>
<Col>
<ListGroup>
......@@ -128,11 +172,13 @@ export class ExplorerMessageQueryResult extends React.Component<Props, any> {
</ListGroup>
</Col>
</Row>
<Row className={"mb-3"}>
<Col>
<h4>Payload</h4>
</Col>
</Row>
<Row className={"mb-3"}>
<Col>
<ListGroup>
......
import {action, computed, observable} from 'mobx';
import {registerHandler, WSMsgType} from "app/misc/WS";
import {PayloadType, DrngSubtype} from "app/misc/Payload";
import {BasicPayload, DrngPayload, DrngCbPayload, ValuePayload} from "app/misc/Payload";
import {BasicPayload, DrngCbPayload, DrngPayload, DrngSubtype, PayloadType, ValuePayload} from "app/misc/Payload";
import * as React from "react";
import {Link} from 'react-router-dom';
import {RouterStore} from "mobx-react-router";
export const GenesisMessageID = "1111111111111111111111111111111111111111111111111111111111111111";
export class Message {
id: string;
timestamp: number;
solidification_timestamp: number;
issuance_timestamp: number;
sequence_number: number;
issuer_public_key: string;
signature: string;
trunk_message_id: string;
branch_message_id: string;
solid: boolean;
......@@ -33,7 +38,7 @@ class MessageRef {
const liveFeedSize = 10;
enum QueryError {
NotFound
NotFound = 1
}
export class ExplorerStore {
......@@ -143,7 +148,7 @@ export class ExplorerStore {
@action
updateAddress = (addr: AddressResult) => {
addr.messages = addr.messages.sort((a, b) => {
return a.timestamp < b.timestamp ? 1 : -1;
return a.solidification_timestamp < b.solidification_timestamp ? 1 : -1;
});
this.addr = addr;
this.query_err = null;
......@@ -155,7 +160,7 @@ export class ExplorerStore {
this.msg = msg;
this.query_err = null;
this.query_loading = false;
switch(msg.payload_type){
switch (msg.payload_type) {
case PayloadType.Drng:
this.payload = msg.payload as DrngPayload
if (this.payload.subpayload_type == DrngSubtype.Cb) {
......
......@@ -220,6 +220,9 @@ export class NodeStore {
@action
updateNeighborMetrics = (neighborMetrics: Array<NeighborMetric>) => {
if (!neighborMetrics) {
return;
}
let updated = [];
for (let i = 0; i < neighborMetrics.length; i++) {
let metric = neighborMetrics[i];
......
This diff is collapsed.
......@@ -18,7 +18,7 @@ const (
)
func init() {
flag.String(CfgBindAddress, "127.0.0.1", "the bind address of the dashboard")
flag.String(CfgBindAddress, "127.0.0.1:8081", "the bind address of the dashboard")
flag.Bool(CfgDev, false, "whether the dashboard runs in dev mode")
flag.Bool(CfgBasicAuthEnabled, false, "whether to enable HTTP basic auth")
flag.String(CfgBasicAuthUsername, "goshimmer", "HTTP basic auth username")
......
......@@ -130,13 +130,13 @@ func configure(*node.Plugin) {
func run(*node.Plugin) {
if err := daemon.BackgroundWorker("_tangle[MissingMessagesMonitor]", func(shutdownSignal <-chan struct{}) {
if err := daemon.BackgroundWorker("Tangle[MissingMessagesMonitor]", func(shutdownSignal <-chan struct{}) {
_tangle.MonitorMissingMessages(shutdownSignal)
}, shutdown.PriorityMissingMessagesMonitoring); err != nil {
log.Panicf("Failed to start as daemon: %s", err)
}
if err := daemon.BackgroundWorker("_tangle", func(shutdownSignal <-chan struct{}) {
if err := daemon.BackgroundWorker("Tangle", func(shutdownSignal <-chan struct{}) {
<-shutdownSignal
messageFactory.Shutdown()
messageParser.Shutdown()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment