import { Connector } from '../../connectors/Connector' ; import { BlockHeader , BlockMsg , Cid , SyncState , TipSetKey } from '../Types' ; /**
 * The Sync method group contains methods for interacting with and observing the lotus sync service.
 */ export class JsonRpcSyncMethodGroup { private conn : Connector ; constructor ( conn ) { this . conn = conn ; } /**
     * returns the current status of the lotus sync system.
     */ public async state ( ) { const state = await this . conn . request ( { method : 'Filecoin.SyncState' } ) ; return state ; } param blockCid public async checkBad ( blockCid ) { const check = await this . conn . request ( { method : 'Filecoin.SyncCheckBad' , params : [ blockCid ] } ) ; return check ; } param blockCid public async markBad ( blockCid ) { await this . conn . request ( { method : 'Filecoin.SyncMarkBad' , params : [ blockCid ] } ) ; } /**
     * purges bad block cache, making it possible to sync to chains previously marked as bad
     */ public async unmarkAllBad ( ) { await this . conn . request ( { method : 'Filecoin.SyncUnmarkAllBad' , params : [ ] } ) ; } param blockCid public async unmarkBad ( blockCid ) { await this . conn . request ( { method : 'Filecoin.SyncUnmarkBad' , params : [ blockCid ] } ) ; } param tipSetKey public async checkpoint ( tipSetKey ) { const check = await this . conn . request ( { method : 'Filecoin.SyncCheckpoint' , params : [ tipSetKey ] } ) ; return check ; } param blockMsg public async submitBlock ( blockMsg ) { const check = await this . conn . request ( { method : 'Filecoin.SyncSubmitBlock' , params : [ blockMsg ] } ) ; return check ; } param cb public async incomingBlocks ( cb ) { const subscriptionId = await this . conn . request ( { method : 'Filecoin.SyncIncomingBlocks' } ) ; this . conn . on ( subscriptionId , cb ) ; } param tipSetKey public async validateTipset ( tipSetKey ) { const valid = await this . conn . request ( { method : 'Filecoin.SyncValidateTipset' , params : [ tipSetKey ] } ) ; return valid ; } }