message: Fixed local orderer for webpack component loader
diff: @@ -213,6 +213,7 @@ export class LocalOrderer implements IOrderer {
  public broadcasterLambda: LocalLambdaController | undefined;
  private readonly socketPublisher: LocalSocketPublisher;
  + private readonly dbObject: IDocument;
  private existing: boolean;
  constructor(
  @@ -236,6 +237,7 @@ export class LocalOrderer implements IOrderer {
  private readonly scribeNackOnSummarizeException: boolean,
  ) {
  this.existing = details.existing;
  + this.dbObject = this.getDeliState();
  this.socketPublisher = new LocalSocketPublisher(this.pubSub);
  this.setupKafkas();
  @@ -293,7 +295,8 @@ export class LocalOrderer implements IOrderer {
  }
  private setupKafkas() {
  - this.rawDeltasKafka = new LocalKafka(this.existing ? this.details.value.logOffset : 0);
  + const deliState: IDeliCheckpoint = JSON.parse(this.dbObject.deli);
  + this.rawDeltasKafka = new LocalKafka(deliState.logOffset + 1);
  this.deltasKafka = new LocalKafka();
  }
  @@ -340,15 +343,11 @@ export class LocalOrderer implements IOrderer {
  this.deliContext,
  async (lambdaSetup, context) => {
  const documentCollection = await lambdaSetup.documentCollectionP();
  - const dbObject: IDocument = this.details.value;
  - if (dbObject.deli === undefined || dbObject.deli === null) {
  - dbObject.deli = JSON.stringify(DefaultDeli);
  - }
  return new DeliLambda(
  context,
  this.tenantId,
  this.documentId,
  - dbObject,
  + this.dbObject,
  documentCollection,
  this.deltasKafka,
  this.rawDeltasKafka,
  @@ -372,12 +371,7 @@ export class LocalOrderer implements IOrderer {
  setup.scribeMessagesP(),
  ]);
  - const dbObject = this.details.value;
  - const scribe: IScribe = (dbObject.scribe === undefined || dbObject.scribe === null)
  - ? DefaultScribe
  - : typeof this.details.value.scribe === "string" ?
  - JSON.parse(this.details.value.scribe) :
  - this.details.value.scribe;
  + const scribe = this.getScribeState();
  const lastState = scribe.protocolState
  ? scribe.protocolState
  : { members: [], proposals: [], values: [] };
  @@ -468,4 +462,22 @@ export class LocalOrderer implements IOrderer {
  this.broadcasterLambda = undefined;
  }
  }
  +
  + private getDeliState(): IDocument {
  + const dbObject: IDocument = this.details.value;
  + if (dbObject.deli === undefined || dbObject.deli === null) {
  + dbObject.deli = JSON.stringify(DefaultDeli);
  + }
  + return dbObject;
  + }
  +
  + private getScribeState(): IScribe {
  + const dbObject: IDocument = this.details.value;
  + const scribe: IScribe = (dbObject.scribe === undefined || dbObject.scribe === null)
  + ? DefaultScribe
  + : typeof this.details.value.scribe === "string" ?
  + JSON.parse(this.details.value.scribe) :
  + this.details.value.scribe;
  + return scribe;
  + }
  }
  