Nodes holds all nodes for all services in two lists - one active for the number of parallel open connections, and one reserve pool for connections that can take over if the active list fails.

It does some advanced checking of which nodes to contact using the following steps:

- sorting the nodes to contact by response time - fastest get contacted first
- failing nodes are replaced by currently unused nodes
- if a node is slower than the slowThreshold, the node is replaced with a node from the reserve pool

### Hierarchy

- Nodes

## Index

### Constructors

- constructor

### Properties

- nodeList
- slowThreshold

### Methods

- done
- gotError
- index
- newList
- replaceActive
- setTimeout
- splitList
- swapNodes

## Constructors

### constructor

- new Nodes(r: Roster, previous?: Nodes): Nodes

- - Defined in src/network/nodes.ts:75

  #### Parameters

  - ##### r: Roster

  - ##### Optional previous: Nodes

  #### Returns Nodes

## Properties

### Private nodeList

nodeList: Node[] = []

- Defined in src/network/nodes.ts:75

### Static slowThreshold

slowThreshold: number = 10

- Defined in src/network/nodes.ts:71

## Methods

### done

- done(address: string, rang: number, ratio: number): void

- - Defined in src/network/nodes.ts:124

  Marks the node with the given address as having successfully treated the message. It will re-order the nodes to reflect order of arrival. If the node is more than 10x slower than the fastest node, it will be replaced with a node from the reserve queue.

  #### Parameters

  - ##### address: string

    node with successful return

  - ##### rang: number

    order of arrival

  - ##### ratio: number

    delay in answer between first reply and this reply

  #### Returns void

### gotError

- gotError(address: string): void

- - Defined in src/network/nodes.ts:111

  Marks the node of the given address as having an error. The error must be a websocket-error 1001 or higher. An error in the request itself (refused transaction) should be treated as a passing node.

  #### Parameters

  - ##### address: string

  #### Returns void

### Private index

- index(address: string): number

- - Defined in src/network/nodes.ts:181

  Gets the index of a given address.

  #### Parameters

  - ##### address: string

  #### Returns number

### newList

- newList(service: string, parallel: number): NodeList

- - Defined in src/network/nodes.ts:101

  Creates a new NodeList for one message.

  #### Parameters

  - ##### service: string

    which service to use

  - ##### parallel: number

    how many calls will run in parallel

  #### Returns NodeList

### Private replaceActive

- replaceActive(index: number): void

- - Defined in src/network/nodes.ts:158

  Replaces the given node from the active queue with the first node from the reserve queue.

  #### Parameters

  - ##### index: number

  #### Returns void

### setTimeout

- setTimeout(t: number): void

- - Defined in src/network/nodes.ts:139

  Sets the timeout on all nodes.

  #### Parameters

  - ##### t: number

  #### Returns void

### splitList

- splitList(active: number, service: string): [IConnection[], IConnection[]]

- - Defined in src/network/nodes.ts:148

  Returns the IConnections corresponding to the active list and the reserve nodes.

  #### Parameters

  - ##### active: number

    how many active nodes to return

  - ##### service: string

    the chosen service

  #### Returns [IConnection[], IConnection[]]

### Private swapNodes

- swapNodes(a: number, b: number): void

- - Defined in src/network/nodes.ts:167

  Swaps two nodes in the active queue.

  #### Parameters

  - ##### a: number

  - ##### b: number

  #### Returns void

Generated using TypeDoc