Class: ServicesBitfield

bitmessage/structs. ServicesBitfield

new ServicesBitfield(bufopt, optsopt)

Service features bitfield (MSB 0).

Parameters:
Name Type Attributes Description
buf Buffer <optional>

A 8-byte bitfield buffer (will be created if not provided or will be copied if opts.copy is true)

opts Object <optional>

Options

Source:
See:
Example
var ServicesBitfield = require("bitmessage").structs.ServicesBitfield;
var services = ServicesBitfield().set(ServicesBitfield.NODE_NETWORK);
console.log(services.get(ServicesBitfield.NODE_NETWORK));  // true
console.log(services.get(15));  // false

Members

(static, constant) NODE_NETWORK :number

Bit index indicating normal network node.

Type:
  • number
Source:

buffer :Buffer

The contents of the bitfield.

Type:
  • Buffer
Source:

Methods

get(index) → {boolean}

Returns a boolean indicating whether the bit is set.

Parameters:
Name Type Description
index number

Bit index (MSB 0)

Source:
Returns:
Type
boolean

set(index) → {Object}

Set the given bit(s) to 1.

Parameters:
Name Type Description
index number | Array.<number>

Bit(s) index (MSB 0)

Source:
Returns:

Returns self so methods can be chained.

Type
Object