Working on map view

This commit is contained in:
maciejhirsz
2018-07-14 22:56:20 +02:00
parent bcc7145477
commit 2c073eac19
16 changed files with 308 additions and 64 deletions
+22 -12
View File
@@ -1,10 +1,13 @@
import { Opaque, Maybe } from './helpers';
import {
FeedVersion,
Latitude,
Longitude,
NodeId,
NodeCount,
NodeDetails,
NodeStats,
NodeLocation,
BlockNumber,
BlockDetails,
Timestamp,
@@ -13,17 +16,18 @@ import {
} from './types';
export const Actions = {
FeedVersion: 255 as 255,
BestBlock: 0 as 0,
AddedNode: 1 as 1,
RemovedNode: 2 as 2,
ImportedBlock: 3 as 3,
NodeStats: 4 as 4,
TimeSync: 5 as 5,
AddedChain: 6 as 6,
RemovedChain: 7 as 7,
SubscribedTo: 8 as 8,
UnsubscribedFrom: 9 as 9
FeedVersion : 0xff as 0xff,
BestBlock : 0x00 as 0x00,
AddedNode : 0x01 as 0x01,
RemovedNode : 0x02 as 0x02,
LocatedNode : 0x03 as 0x03,
ImportedBlock : 0x04 as 0x04,
NodeStats : 0x05 as 0x05,
TimeSync : 0x06 as 0x06,
AddedChain : 0x07 as 0x07,
RemovedChain : 0x08 as 0x08,
SubscribedTo : 0x09 as 0x09,
UnsubscribedFrom : 0x0A as 0x0A,
};
export type Action = typeof Actions[keyof typeof Actions];
@@ -46,7 +50,7 @@ export namespace Variants {
export interface AddedNodeMessage extends MessageBase {
action: typeof Actions.AddedNode;
payload: [NodeId, NodeDetails, NodeStats, BlockDetails];
payload: [NodeId, NodeDetails, NodeStats, BlockDetails, Maybe<NodeLocation>];
}
export interface RemovedNodeMessage extends MessageBase {
@@ -54,6 +58,11 @@ export namespace Variants {
payload: NodeId;
}
export interface LocatedNodeMessage extends MessageBase {
action: typeof Actions.LocatedNode;
payload: [NodeId, Latitude, Longitude];
}
export interface ImportedBlockMessage extends MessageBase {
action: typeof Actions.ImportedBlock;
payload: [NodeId, BlockDetails];
@@ -95,6 +104,7 @@ export type Message =
| Variants.BestBlockMessage
| Variants.AddedNodeMessage
| Variants.RemovedNodeMessage
| Variants.LocatedNodeMessage
| Variants.ImportedBlockMessage
| Variants.NodeStatsMessage
| Variants.TimeSyncMessage
+1 -2
View File
@@ -1,4 +1,3 @@
export * from './iterators';
export * from './helpers';
export * from './id';
@@ -7,4 +6,4 @@ import * as FeedMessage from './feed';
export { Types, FeedMessage };
export const VERSION: Types.FeedVersion = 2 as Types.FeedVersion;
export const VERSION: Types.FeedVersion = 3 as Types.FeedVersion;
+3
View File
@@ -16,7 +16,10 @@ export type PropagationTime = Opaque<Milliseconds, 'PropagationTime'>;
export type NodeCount = Opaque<number, 'NodeCount'>;
export type PeerCount = Opaque<number, 'PeerCount'>;
export type TransactionCount = Opaque<number, 'TransactionCount'>;
export type Latitude = Opaque<number, 'Latitude'>;
export type Longitude = Opaque<number, 'Longitude'>;
export type BlockDetails = [BlockNumber, BlockHash, Milliseconds, Timestamp, Maybe<PropagationTime>];
export type NodeDetails = [NodeName, NodeImplementation, NodeVersion];
export type NodeStats = [PeerCount, TransactionCount];
export type NodeLocation = [Latitude, Longitude];