mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-06-29 07:41:35 +00:00
Fluence.parseAIR function to return AST as JSON (#994)
This commit is contained in:
@ -27,7 +27,7 @@ import {
|
||||
popParticle,
|
||||
setCurrentParticleId
|
||||
} from "./globalState";
|
||||
import {instantiateStepper, Stepper} from "./stepper";
|
||||
import {instantiateInterpreter, InterpreterInvoke} from "./stepper";
|
||||
import log from "loglevel";
|
||||
import {waitService} from "./helpers/waitService";
|
||||
import {ModuleConfig} from "./moduleConfig";
|
||||
@ -40,7 +40,7 @@ export class FluenceClient {
|
||||
|
||||
private nodePeerIdStr: string;
|
||||
private subscriptions = new Subscriptions();
|
||||
private stepper: Stepper = undefined;
|
||||
private interpreter: InterpreterInvoke = undefined;
|
||||
|
||||
connection: FluenceConnection;
|
||||
|
||||
@ -50,7 +50,7 @@ export class FluenceClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass a particle to a stepper and send a result to other services.
|
||||
* Pass a particle to a interpreter and send a result to other services.
|
||||
*/
|
||||
private async handleParticle(particle: Particle): Promise<void> {
|
||||
|
||||
@ -58,8 +58,8 @@ export class FluenceClient {
|
||||
if (getCurrentParticleId() !== undefined && getCurrentParticleId() !== particle.id) {
|
||||
enqueueParticle(particle);
|
||||
} else {
|
||||
if (this.stepper === undefined) {
|
||||
throw new Error("Undefined. Stepper is not initialized. User 'Fluence.connect' to create a client.")
|
||||
if (this.interpreter === undefined) {
|
||||
throw new Error("Undefined. Interpreter is not initialized. User 'Fluence.connect' to create a client.")
|
||||
}
|
||||
// start particle processing if queue is empty
|
||||
try {
|
||||
@ -81,10 +81,10 @@ export class FluenceClient {
|
||||
// set a particle with actual ttl
|
||||
this.subscriptions.subscribe(particle, actualTtl)
|
||||
}
|
||||
let stepperOutcomeStr = this.stepper(particle.init_peer_id, particle.script, JSON.stringify(prevData), JSON.stringify(particle.data))
|
||||
let stepperOutcomeStr = this.interpreter(particle.init_peer_id, particle.script, JSON.stringify(prevData), JSON.stringify(particle.data))
|
||||
let stepperOutcome: StepperOutcome = JSON.parse(stepperOutcomeStr);
|
||||
|
||||
log.info("inner stepper outcome:");
|
||||
log.info("inner interpreter outcome:");
|
||||
log.info(stepperOutcome);
|
||||
|
||||
// do nothing if there is no `next_peer_pks`
|
||||
@ -162,7 +162,7 @@ export class FluenceClient {
|
||||
|
||||
let peerId = PeerId.createFromB58String(nodePeerId);
|
||||
|
||||
this.stepper = await instantiateStepper(this.selfPeerId);
|
||||
this.interpreter = await instantiateInterpreter(this.selfPeerId);
|
||||
|
||||
let connection = new FluenceConnection(multiaddr, peerId, this.selfPeerId, this.handleExternalParticle());
|
||||
|
||||
|
Reference in New Issue
Block a user