2020-12-23 17:21:23 +00:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2021-04-27 18:51:45 +01:00
|
|
|
/**
|
|
|
|
* Divider to convert payout amounts to cents.
|
|
|
|
*/
|
2021-08-02 18:09:54 +01:00
|
|
|
const PRICE_DIVIDER = 10000;
|
2021-04-27 18:51:45 +01:00
|
|
|
|
2021-01-04 18:17:00 +00:00
|
|
|
/**
|
|
|
|
* Describes node online statuses.
|
|
|
|
*/
|
|
|
|
export enum NodeStatus {
|
|
|
|
Online = 'online',
|
|
|
|
Offline = 'offline',
|
2021-07-05 15:36:10 +01:00
|
|
|
NotReachable = 'not reachable',
|
2021-01-04 18:17:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-21 17:04:42 +00:00
|
|
|
* NodeInfo contains basic node internal state.
|
2021-01-04 18:17:00 +00:00
|
|
|
*/
|
|
|
|
export class Node {
|
2021-01-21 17:04:42 +00:00
|
|
|
public constructor(
|
2021-01-25 18:58:55 +00:00
|
|
|
public id: string = '',
|
|
|
|
public name: string = '',
|
|
|
|
public version: string = '',
|
|
|
|
public lastContact: Date = new Date(),
|
|
|
|
public diskSpaceUsed: number = 0,
|
|
|
|
public diskSpaceLeft: number = 0,
|
|
|
|
public bandwidthUsed: number = 0,
|
|
|
|
public onlineScore: number = 0,
|
|
|
|
public auditScore: number = 0,
|
|
|
|
public suspensionScore: number = 0,
|
|
|
|
public earned: number = 0,
|
2021-07-05 15:36:10 +01:00
|
|
|
public status: string = NodeStatus.Online,
|
|
|
|
) {}
|
2021-01-21 17:04:42 +00:00
|
|
|
|
2021-07-05 15:36:10 +01:00
|
|
|
/**
|
|
|
|
* displayedName handles displayed name of the node.
|
|
|
|
*/
|
2021-01-21 17:04:42 +00:00
|
|
|
public get displayedName(): string {
|
|
|
|
return this.name || this.id;
|
|
|
|
}
|
2021-04-27 18:51:45 +01:00
|
|
|
|
2021-07-05 15:36:10 +01:00
|
|
|
/**
|
|
|
|
* earnedCents returns earned value in cents.
|
|
|
|
*/
|
|
|
|
public get earnedCents(): number {
|
|
|
|
return this.earned / PRICE_DIVIDER;
|
2021-04-27 18:51:45 +01:00
|
|
|
}
|
2021-07-05 15:36:10 +01:00
|
|
|
|
|
|
|
public get statusText(): string {
|
|
|
|
return NodeStatus[this.status];
|
|
|
|
}
|
2021-01-21 17:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CreateNodeFields is a representation of storagenode, that SNO could add to the Multinode Dashboard.
|
|
|
|
*/
|
|
|
|
export class CreateNodeFields {
|
2021-01-04 18:17:00 +00:00
|
|
|
public constructor(
|
|
|
|
public id: string = '',
|
2021-01-21 17:04:42 +00:00
|
|
|
public apiSecret: string = '',
|
|
|
|
public publicAddress: string = '',
|
|
|
|
) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NodeURL defines a structure for connecting to a node.
|
|
|
|
*/
|
|
|
|
export class NodeURL {
|
|
|
|
public constructor(
|
2021-04-30 10:33:36 +01:00
|
|
|
public id: string = '',
|
|
|
|
public address: string = '',
|
2021-01-04 18:17:00 +00:00
|
|
|
) {}
|
|
|
|
}
|
2021-03-01 21:07:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* UpdateNodeModel defines a structure for updating node name.
|
|
|
|
*/
|
|
|
|
export class UpdateNodeModel {
|
|
|
|
public constructor(
|
2021-04-30 10:33:36 +01:00
|
|
|
public id: string = '',
|
|
|
|
public name: string = '',
|
2021-03-01 21:07:46 +00:00
|
|
|
) {}
|
|
|
|
}
|