Namespace: object

bitmessage/structs. object

An object is a message which is shared throughout a stream. It is the only message which propagates; all others are only between two nodes.

Source:
See:

Members

(static, constant) BROADCAST :number

broadcast object type.

Type:
  • number
Source:

(static, constant) GETPUBKEY :number

getpubkey object type.

Type:
  • number
Source:

(static, constant) MSG :number

msg object type.

Type:
  • number
Source:

(static, constant) PUBKEY :number

pubkey object type.

Type:
  • number
Source:

Methods

(static) decode(buf, optsopt) → {DecodeResult}

Decode object message.
NOTE: nonce and objectPayload are copied.

Parameters:
Name Type Attributes Description
buf Buffer

Message

opts Object <optional>

Decoding options

Properties
Name Type Description
allowExpired boolean

Allow expired objects

skipPow boolean

Do not validate object POW

Source:
Throws:

Invalid object

Type
Error
Returns:
Type
DecodeResult

(static) decodePayload()

Decode object message payload. The same as decode.

Source:

(static) encode(opts) → {Buffer}

Encode object message.

Parameters:
Name Type Description
opts Object

Object options

Properties
Name Type Attributes Description
nonce Object

A 8-byte object nonce

ttl number

Time to live in seconds

type number

Object type

version number

Object version

stream number <optional>

Object stream (1 by default)

objectPayload Buffer

Object payload

Source:
Returns:

Encoded message.

Type
Buffer

(static) encodePayload()

Encode object message payload. The same as encode.

Source:

(static) encodePayloadWithoutNonce(opts) → {Buffer}

Encode object message payload without leading nonce field (may be useful if you are going to calculate it later).

Parameters:
Name Type Description
opts Object

Object options

Properties
Name Type Attributes Description
ttl number

Time to live in seconds

type number

Object type

version number

Object version

stream number <optional>

Object stream (1 by default)

objectPayload Buffer

Object payload

Source:
Returns:

Encoded payload.

Type
Buffer

(static) validate(buf, optsopt) → (nullable) {Error}

Check whether given object message is valid.

Parameters:
Name Type Attributes Description
buf Buffer

Message

opts Object <optional>

Any of object.decode options and:

Properties
Name Type Description
stream number

Expected object's stream

Source:
Returns:

Return an error with description if object is invalid.

Type
Error

(static) validatePayload()

Check whether object message payload is valid. The same as validate.

Source:

Type Definitions

DecodeResult

Type:
  • Object
Properties:
Name Type Description
nonce Buffer

A 8-byte object nonce

ttl number

Time to live in seconds

expires Date

Object expiration date

type number

Object type

version number

Object version

stream number

Object stream

headerLength number

Length of the object header

objectPayload Buffer

Object payload

Source: