···11# frozen_string_literal: true
2233+require_relative '../car_archive'
34require_relative '../firehose'
45require_relative 'message'
5667module Skyfall
88+99+ #
1010+ # Firehose message which declares the current state of the repository. The message is meant to
1111+ # trigger a resynchronization of the repository from a receiving consumer, if the consumer detects
1212+ # from the message rev that it must have missed some events from that repository.
1313+ #
1414+ # The sync message can be emitted by a PDS or relay to force a repair of a broken account state,
1515+ # or e.g. when an account is created, migrated or recovered from a CAR backup.
1616+ #
1717+718 class Firehose::SyncMessage < Firehose::Message
1919+2020+ #
2121+ # @private
2222+ # @param type_object [Hash] first decoded CBOR frame with metadata
2323+ # @param data_object [Hash] second decoded CBOR frame with payload
2424+ # @raise [DecodeError] if the message doesn't include required data
2525+ #
2626+ def initialize(type_object, data_object)
2727+ super
2828+ check_if_not_nil 'seq', 'did', 'blocks', 'rev', 'time'
2929+ end
3030+831 def rev
932 @rev ||= @data_object['rev']
3333+ end
3434+3535+ # @return [Skyfall::CarArchive] commit data in the form of a parsed CAR archive
3636+ def blocks
3737+ @blocks ||= CarArchive.new(@data_object['blocks'])
1038 end
1139 end
1240end