iota-gateway
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "iota-gateway", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Network gateway for IOTA", | ||
@@ -31,2 +31,3 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@types/node": "^9.3.0", | ||
"iota-tangle": "0.0.6" | ||
@@ -38,3 +39,2 @@ }, | ||
"@types/mocha": "^2.2.46", | ||
"@types/node": "^9.3.0", | ||
"@types/sinon": "^4.1.2", | ||
@@ -41,0 +41,0 @@ "@types/sinon-chai": "^2.7.29", |
@@ -19,3 +19,3 @@ import { Transaction, Hash } from 'iota-tangle' | ||
constructor (params: { | ||
constructor(params: { | ||
neighbors?: Neighbor[] | ||
@@ -51,7 +51,7 @@ transports?: Transport[] | ||
get isRunning (): boolean { | ||
get isRunning(): boolean { | ||
return this._isRunning | ||
} | ||
getNeighbor (neighborAddress: string): Neighbor | null { | ||
getNeighbor(neighborAddress: string): Neighbor | null { | ||
for (const neighbor of this._neighbors) { | ||
@@ -66,3 +66,3 @@ if (neighbor.match(neighborAddress)) { | ||
async addNeighbor (neighbor: Neighbor): Promise<void> { | ||
async addNeighbor(neighbor: Neighbor): Promise<void> { | ||
if (this._neighborsTransportsMap.has(neighbor)) { | ||
@@ -87,3 +87,3 @@ throw new Error(`Couldn't add a neighbor: the neighbor '${neighbor.address}' already exists!`) | ||
async removeNeighbor (neighbor: Neighbor): Promise<void> { | ||
async removeNeighbor(neighbor: Neighbor): Promise<void> { | ||
if (!this._neighborsTransportsMap.has(neighbor)) { | ||
@@ -101,3 +101,3 @@ throw new Error(`Couldn't remove a neighbor: the neighbor '${neighbor.address}' doesn't exists!`) | ||
async run (): Promise<void> { | ||
async run(): Promise<void> { | ||
if (this._isRunning) { | ||
@@ -148,3 +148,3 @@ throw new Error('The gateway is already running!') | ||
async shutdown (): Promise<void> { | ||
async shutdown(): Promise<void> { | ||
if (!this._isRunning) { | ||
@@ -174,3 +174,3 @@ throw new Error('The gateway is not running!') | ||
async send (data: Data, neighborAddress: string): Promise<void> { | ||
async send(data: Data, neighborAddress: string): Promise<void> { | ||
if (!this._isRunning) { | ||
@@ -177,0 +177,0 @@ throw new Error("Can't send a data: the gateway is not running!") |
export abstract class Neighbor { | ||
abstract get address (): string | ||
abstract get address(): string | ||
get gatewayCanSendTo (): boolean { | ||
get gatewayCanSendTo(): boolean { | ||
return true | ||
} | ||
get gatewayCanReceiveFrom (): boolean { | ||
get gatewayCanReceiveFrom(): boolean { | ||
return true | ||
} | ||
match (address: string): boolean { | ||
match(address: string): boolean { | ||
return this.address === address | ||
} | ||
} |
@@ -19,7 +19,7 @@ import { Transaction, Factory } from 'iota-tangle' | ||
get packetSize (): number { | ||
get packetSize(): number { | ||
return PACKET_SIZE | ||
} | ||
pack (data: Data): Buffer { | ||
pack(data: Data): Buffer { | ||
const buffer = Buffer.alloc(PACKET_SIZE) | ||
@@ -33,3 +33,3 @@ | ||
unpack (packet: Buffer): Data { | ||
unpack(packet: Buffer): Data { | ||
const transactionBytes = packet.slice(TRANSCTION_OFFSET, TRANSCTION_OFFSET + TRANSACTION_SIZE) | ||
@@ -36,0 +36,0 @@ const hashBytes = packet.slice(REQUEST_HASH_OFFSET, REQUEST_HASH_OFFSET + REQUEST_HASH_SIZE) |
@@ -6,13 +6,13 @@ import { EventEmitter } from 'events' | ||
export abstract class Transport extends EventEmitter { | ||
abstract get isRunning (): boolean | ||
abstract get isRunning(): boolean | ||
abstract supports (neighbor: Neighbor): boolean | ||
abstract supports(neighbor: Neighbor): boolean | ||
abstract async run (): Promise<void> | ||
abstract async shutdown (): Promise<void> | ||
abstract async run(): Promise<void> | ||
abstract async shutdown(): Promise<void> | ||
abstract async addNeighbor (neighbor: Neighbor): Promise<void> | ||
abstract async removeNeighbor (neighbor: Neighbor): Promise<void> | ||
abstract async addNeighbor(neighbor: Neighbor): Promise<void> | ||
abstract async removeNeighbor(neighbor: Neighbor): Promise<void> | ||
abstract async send (data: Data, neighbor: Neighbor): Promise<void> | ||
abstract async send(data: Data, neighbor: Neighbor): Promise<void> | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12
48648
2
+ Added@types/node@^9.3.0
+ Added@types/node@9.6.61(transitive)