Class: HostList

net.HostList

new HostList(options)

Host List

Parameters:
Name Type Description
options Object
Source:

Methods

(static) fromJSON(options, json) → {HostList}

Instantiate host list from json object.

Parameters:
Name Type Description
options Object
json Object
Source:
Returns:
Type
HostList

(private) _init()

Initialize list.

Source:

(private) _initOptions()

Initialize options.

Source:

add(addr, srcnullable) → {Boolean}

Add host to host list.

Parameters:
Name Type Attributes Description
addr NetAddress
src NetAddress <nullable>
Source:
Returns:
Type
Boolean

addNode(host)

Add a priority node.

Parameters:
Name Type Description
host String
Source:

addSeed(host)

Add a preferred seed.

Parameters:
Name Type Description
host String
Source:

ban(host)

Mark a peer as banned.

Parameters:
Name Type Description
host String
Source:

clearBanned()

Clear banned hosts.

Source:

discover() → {Promise}

Discover hosts from seeds and nodes.

Source:
Returns:
Type
Promise

evictFresh(bucket)

Evict a host from fresh bucket.

Parameters:
Name Type Description
bucket Map
Source:

evictUsed(bucket)

Pick used for eviction.

Parameters:
Name Type Description
bucket List
Source:

(private) freshBucket(entry) → {Map}

Get fresh bucket for host.

Parameters:
Name Type Description
entry HostEntry
Source:
Returns:
Type
Map

(private) fromJSON(json) → {HostList}

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:
Returns:
Type
HostList

getHost() → {HostEntry}

Allocate a new host.

Source:
Returns:
Type
HostEntry

isBanned(host) → {Boolean}

Test whether the host is banned.

Parameters:
Name Type Description
host String
Source:
Returns:
Type
Boolean

isFull() → {Boolean}

Test whether the host list is full.

Source:
Returns:
Type
Boolean

isStale(entry) → {Boolean}

Test whether a host is evictable.

Parameters:
Name Type Description
entry HostEntry
Source:
Returns:
Type
Boolean

markAck(hostname, services)

Mark host as successfully ack'd.

Parameters:
Name Type Description
hostname String
services Number
Source:

markAttempt(hostname)

Mark host as failed.

Parameters:
Name Type Description
hostname String
Source:

markSuccess(hostname)

Mark host as successfully connected.

Parameters:
Name Type Description
hostname String
Source:

populate(target) → {Promise}

Lookup hosts from dns host.

Parameters:
Name Type Description
target Object
Source:
Returns:
Type
Promise

populateNode(addr) → {Promise}

Lookup node's domain.

Parameters:
Name Type Description
addr Object
Source:
Returns:
Type
Promise

populateSeed(seed) → {Promise}

Populate from seed.

Parameters:
Name Type Description
seed Object
Source:
Returns:
Type
Promise

remove(hostname) → {NetAddress}

Remove host from host list.

Parameters:
Name Type Description
hostname String
Source:
Returns:
Type
NetAddress

reset()

Reset host list.

Source:

setNodes(nodes)

Set priority nodes.

Parameters:
Name Type Description
nodes Array:.<String:>
Source:

setSeeds(seeds)

Set initial seeds.

Parameters:
Name Type Description
seeds Array:.<String:>
Source:

size() → {Number}

Get list size.

Source:
Returns:
Type
Number

toArray() → {Array:.<NetAddress:>}

Convert address list to array.

Source:
Returns:
Type
Array:.<NetAddress:>

toJSON() → {Object}

Convert host list to json-friendly object.

Source:
Returns:
Type
Object

unban(host)

Unban host.

Parameters:
Name Type Description
host String
Source:

(private) usedBucket(entry) → {List}

Get used bucket for host.

Parameters:
Name Type Description
entry HostEntry
Source:
Returns:
Type
List