Class: Skyfall::Firehose::SyncMessage

Inherits:
Firehose::Message
  • Object
show all
Defined in:
lib/skyfall/firehose/sync_message.rb

Overview

Firehose message which declares the current state of the repository. The message is meant to trigger a resynchronization of the repository from a receiving consumer, if the consumer detects from the message rev that it must have missed some events from that repository.

The sync message can be emitted by a PDS or relay to force a repair of a broken account state, or e.g. when an account is created, migrated or recovered from a CAR backup.

Instance Method Summary collapse

Constructor Details

#initialize(type_object, data_object) ⇒ SyncMessage

Returns a new instance of SyncMessage.

Parameters:

  • type_object (Hash)

    first decoded CBOR frame with metadata

  • data_object (Hash)

    second decoded CBOR frame with payload

Raises:

  • (DecodeError)

    if the message doesn't include required data



26
27
28
29
# File 'lib/skyfall/firehose/sync_message.rb', line 26

def initialize(type_object, data_object)
  super
  check_if_not_nil 'seq', 'did', 'blocks', 'rev', 'time'
end

Instance Method Details

#blocksOxygene::CARArchive

Returns commit data in the form of a parsed CAR archive.

Returns:

  • (Oxygene::CARArchive)

    commit data in the form of a parsed CAR archive



36
37
38
# File 'lib/skyfall/firehose/sync_message.rb', line 36

def blocks
  @blocks ||= Oxygene::CARArchive.new(@data_object['blocks'])
end

#revObject



31
32
33
# File 'lib/skyfall/firehose/sync_message.rb', line 31

def rev
  @rev ||= @data_object['rev']
end