fetchWork() {
    if(this.detailsCache === null)
      throw new Error('REQUIRED_DETAILS');

    const nextWorkHash = (this.detailsCache.history.length === 0 ?
      keyFromAccount(this.address) : this.detailsCache.info.frontier);

    if(this.data.workHash === nextWorkHash && this.data.workValue instanceof Promise) {
        return this.data.workValue;
    } else if(this.data.workHash === nextWorkHash && typeof this.data.workValue === 'string') {
        return Promise.resolve({
          work: this.data.workValue,
          details: this.detailsCache
        });
    } else {
      this.data.workHash = nextWorkHash;
      return this.data.workValue = this.wallet.app.queueWork(nextWorkHash)
        .then(data => {
          if(this.data.workHash === nextWorkHash)
            this.data.workValue = data;

          this.wallet.app.saveWallet();

          return {
            details: this.detailsCache,
            work: data
          };
        })
        .catch(reason => {
          if(reason === 'GENERATION_STOPPED') this.data.workValue = null;
          else throw reason;
        });
    }
  }
/*
    Fetch work from backend if not already cached
    @return Promise { work, details }
    */
Fetch work from backend if not already cached
Fetch work from backend if not already cached
fetchWork() {
    if(this.detailsCache === null)
      throw new Error('REQUIRED_DETAILS');
    const nextWorkHash = (this.detailsCache.history.length === 0 ?
      keyFromAccount(this.address) : this.detailsCache.info.frontier);
    if(this.data.workHash === nextWorkHash && this.data.workValue instanceof Promise) {
        return this.data.workValue;
    } else if(this.data.workHash === nextWorkHash && typeof this.data.workValue === 'string') {
        return Promise.resolve({
          work: this.data.workValue,
          details: this.detailsCache
        });
    } else {
      this.data.workHash = nextWorkHash;
      return this.data.workValue = this.wallet.app.queueWork(nextWorkHash)
        .then(data => {
          if(this.data.workHash === nextWorkHash)
            this.data.workValue = data;
          this.wallet.app.saveWallet();
          return {
            details: this.detailsCache,
            work: data
          };
        })
        .catch(reason => {
          if(reason === 'GENERATION_STOPPED') this.data.workValue = null;
          else throw reason;
        });
    }
  }
fetchWork ( ) { if ( this . detailsCache === null ) throw new Error ( 'REQUIRED_DETAILS' ) ; const nextWorkHash = ( this . detailsCache . history . length === 0 ? keyFromAccount ( this . address ) : this . detailsCache . info . frontier ) ; if ( this . data . workHash === nextWorkHash && this . data . workValue instanceof Promise ) { return this . data . workValue ; } else if ( this . data . workHash === nextWorkHash && typeof this . data . workValue === 'string' ) { return Promise . resolve ( { work : this . data . workValue , details : this . detailsCache } ) ; } else { this . data . workHash = nextWorkHash ; return this . data . workValue = this . wallet . app . queueWork ( nextWorkHash ) . then ( data => { if ( this . data . workHash === nextWorkHash ) this . data . workValue = data ; this . wallet . app . saveWallet ( ) ; return { details : this . detailsCache , work : data } ; } ) . catch ( reason => { if ( reason === 'GENERATION_STOPPED' ) this . data . workValue = null ; else throw reason ; } ) ; } }
Fetch work from backend if not already cached
Fetch work from backend if not already cached