Skip to main content

LocalCloud

LocalCloud is a cloud that runs on the local machine for testing and development It uses LocalStorage to store jobs, tasks, transactions, and data It uses a localWorker to execute the tasks It can be used to test the cloud functionality without deploying to the cloud

@param

the worker to execute the tasks

Hierarchy

Index

Constructors

constructor

  • Constructor for LocalCloud


    Parameters

    Returns LocalCloud

Properties

optionalreadonlyargs

args?: string

readonlycache

cache: string

readonlychain

chain: blockchain

readonlydeveloper

developer: string

readonlyid

id: string

readonlyisLocalCloud

isLocalCloud: boolean

readonlyjobId

jobId: string

readonlylocalWorker

localWorker: (cloud: Cloud) => Promise<zkCloudWorker>

Type declaration

optionalreadonlymetadata

metadata?: string

readonlyrepo

repo: string

readonlystepId

stepId: string

optionalreadonlytask

task?: string

readonlytaskId

taskId: string

optionalreadonlyuserId

userId?: string

Methods

publicaddTask

  • addTask(data: { args?: string; metadata?: string; startTime?: number; task: string; userId?: string }): Promise<string>
  • Adds a task to the local cloud


    Parameters

    • data: { args?: string; metadata?: string; startTime?: number; task: string; userId?: string }

      the data to use

    Returns Promise<string>

    the task id

publicdecrypt

  • decrypt(params: { context: string; data: string; keyId?: string }): Promise<undefined | string>
  • Decrypts the data


    Parameters

    • params: { context: string; data: string; keyId?: string }

    Returns Promise<undefined | string>

publicdeleteTask

  • deleteTask(taskId: string): Promise<void>
  • Deletes a task from the local cloud


    Parameters

    • taskId: string

      the task id to delete

    Returns Promise<void>

publicdeleteTransaction

  • deleteTransaction(txId: string): Promise<void>
  • Deletes a transaction from the local cloud


    Parameters

    • txId: string

      the transaction id to delete

    Returns Promise<void>

publicencrypt

  • encrypt(params: { context: string; data: string; keyId?: string }): Promise<undefined | string>
  • Encrypts the data


    Parameters

    • params: { context: string; data: string; keyId?: string }

    Returns Promise<undefined | string>

    encrypted data

publicexecute

  • execute(data: { args?: string; metadata?: string; task: string; transactions: string[]; userId?: string }): Promise<string>
  • Executes the task in the local cloud


    Parameters

    • data: { args?: string; metadata?: string; task: string; transactions: string[]; userId?: string }

      the data to use

    Returns Promise<string>

    the job id

forceWorkerRestart

  • forceWorkerRestart(): Promise<void>
  • forces the worker to restart


    Returns Promise<void>

publicgetDataByKey

  • getDataByKey(key: string): Promise<undefined | string>
  • Gets the data by key


    Parameters

    • key: string

      the key to get the data

    Returns Promise<undefined | string>

    the data

publicgetDeployer

  • Provides the deployer key pair for testing and development


    Returns Promise<undefined | DeployerKeyPair>

    the deployer key pair

publicgetTransactions

  • Abstract method to get the transactions Used to get the transactions


    Returns Promise<CloudTransaction[]>

    the transactions

publicjobResult

  • jobResult(jobId: string): Promise<undefined | JobData>
  • Gets the job result


    Parameters

    • jobId: string

      the job id

    Returns Promise<undefined | JobData>

    the job data

publicloadFile

  • loadFile(filename: string): Promise<undefined | Buffer>
  • Loads the file


    Parameters

    • filename: string

    Returns Promise<undefined | Buffer>

    the file data

publicprocessTasks

  • processTasks(): Promise<void>
  • Processes the tasks in the local cloud


    Returns Promise<void>

publicpublishTransactionMetadata

  • publishTransactionMetadata(params: { metadata: TransactionMetadata; txId: string }): Promise<void>
  • Publish the transaction metadata in human-readable format


    Parameters

    Returns Promise<void>

publicrecursiveProof

  • recursiveProof(data: { args?: string; metadata?: string; task?: string; transactions: string[]; userId?: string }): Promise<string>
  • Runs the recursive proof in the local cloud


    Parameters

    • data: { args?: string; metadata?: string; task?: string; transactions: string[]; userId?: string }

      the data to use

    Returns Promise<string>

    the job id

publicreleaseDeployer

  • releaseDeployer(params: { publicKey: string; txsHashes: string[] }): Promise<void>
  • Releases the deployer key pair


    Parameters

    • params: { publicKey: string; txsHashes: string[] }

    Returns Promise<void>

publicsaveDataByKey

  • saveDataByKey(key: string, value: undefined | string): Promise<void>
  • Saves the data by key


    Parameters

    • key: string

      the key to save the data

    • value: undefined | string

      the value to save

    Returns Promise<void>

publicsaveFile

  • saveFile(filename: string, value: Buffer): Promise<void>
  • Saves the file


    Parameters

    • filename: string

      the filename to save

    • value: Buffer

      the value to save

    Returns Promise<void>

publicsendTransactions

  • Send transactions to the local cloud


    Parameters

    • transactions: string[]

      the transactions to add

    Returns Promise<CloudTransaction[]>

    the transaction ids

publicstaticaddTransactions

  • Adds transactions to the local cloud


    Parameters

    Returns Promise<CloudTransaction[]>

    the transaction ids

staticprocessLocalTasks

  • processLocalTasks(params: { chain: blockchain; developer: string; localWorker: (cloud: Cloud) => Promise<zkCloudWorker>; repo: string }): Promise<number>
  • Processes the local tasks


    Parameters

    • params: { chain: blockchain; developer: string; localWorker: (cloud: Cloud) => Promise<zkCloudWorker>; repo: string }

      the parameters to process the local tasks

    Returns Promise<number>

publicstaticrun

  • run(params: { chain: blockchain; command: ApiCommand; data: { args?: string; developer: string; metadata?: string; repo: string; task: string; transactions: string[]; userId?: string }; localWorker: (cloud: Cloud) => Promise<zkCloudWorker> }): Promise<string>
  • Runs the worker in the local cloud


    Parameters

    • params: { chain: blockchain; command: ApiCommand; data: { args?: string; developer: string; metadata?: string; repo: string; task: string; transactions: string[]; userId?: string }; localWorker: (cloud: Cloud) => Promise<zkCloudWorker> }

      the parameters to run the worker

    Returns Promise<string>

    the job id

staticsequencer

  • sequencer(params: { data: { args?: string; developer: string; metadata?: string; repo: string; task?: string; transactions: string[]; userId?: string }; worker: zkCloudWorker }): Promise<string>
  • Runs the sequencer in the local cloud


    Parameters

    • params: { data: { args?: string; developer: string; metadata?: string; repo: string; task?: string; transactions: string[]; userId?: string }; worker: zkCloudWorker }

      the parameters to run the sequencer

    Returns Promise<string>

    the proof