How to use the @reactivex/ix-es2015-cjs/asynciterable/pipe/scan.scan function in @reactivex/ix-es2015-cjs

To help you get started, we’ve selected a few @reactivex/ix-es2015-cjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neo-one-suite / neo-one / packages / neo-one-node-consensus / src / Consensus.ts View on Github external
private async startInternal(options: InternalOptions): Promise {
    logger.info({ name: 'neo_consensus_start' }, 'Consensus started.');

    const initialResult = await initializeNewConsensus({
      blockchain: this.node.blockchain,
      publicKey: options.publicKey,
      consensusContext: this.mutableConsensusContext,
    });

    await AsyncIterableX.from(this.mutableQueue)
      .pipe(
        scan(async (context: Context, event: Event) => {
          let result;
          switch (event.type) {
            case 'handlePersistBlock':
              result = await handlePersistBlock({
                blockchain: this.node.blockchain,
                publicKey: options.publicKey,
                consensusContext: this.mutableConsensusContext,
              });

              break;
            case 'handleConsensusPayload':
              result = await handleConsensusPayload({
                context,
                node: this.node,
                privateKey: options.privateKey,
                payload: event.payload,