private dynamic dispatchEngineMethod(EngineMethod method, dynamic args) { switch (method) { case EngineMethod.create: TriggerType trigger = (TriggerType)args.trigger; long gas = long.Parse((string)args.gas); bool testMode = (bool)args.testMode; IVerifiable container = null; if (args.container != null) { container = deserializeContainer(args.container); } return(this._create(trigger, container, this.selectSnapshot(args.snapshot, false), gas, testMode)); case EngineMethod.execute: return(this._execute()); case EngineMethod.loadscript: Script script = new Script((byte[])args.script); CallFlags flag = (CallFlags)((byte)args.flag); return(this._loadScript(script, flag)); case EngineMethod.setinstructionpointer: int position = (int)args.position; return(this._setInstructionPointer(position)); case EngineMethod.getvmstate: return(this._getVMState()); case EngineMethod.getresultstack: return(this._getResultStack()); case EngineMethod.gettrigger: return(this._getTrigger()); case EngineMethod.getgasconsumed: return(this._getGasConsumed()); case EngineMethod.getnotifications: return(this._getNotifications()); case EngineMethod.dispose_engine: this.disposeEngine(); return(true); default: throw new InvalidOperationException(); } }
private dynamic dispatchEngineMethod(EngineMethod method, dynamic args) { switch (method) { case EngineMethod.create: TriggerType trigger = (TriggerType)args.trigger; long gas = long.Parse((string)args.gas); IVerifiable container = null; if (args.container != null) { container = deserializeContainer(args.container); } Block persistingBlock = null; if (args.persistingBlock != null) { persistingBlock = new Block(); using (MemoryStream ms = new MemoryStream(args.persistingBlock)) using (BinaryReader reader = new BinaryReader(ms)) { persistingBlock.Deserialize(reader); } } ProtocolSettings settings = ProtocolSettings.Default; if (args.settings != null) { settings = ProtocolSettings.Load(parseConfig(args.settings)); } return(this._create(trigger, container, this.selectSnapshot(args.snapshot, false), persistingBlock, settings, gas)); case EngineMethod.execute: return(this._execute()); case EngineMethod.loadscript: Script script = new Script((byte[])args.script); CallFlags flags = (CallFlags)((byte)args.flags); UInt160 scriptHash = null; int initialPosition = 0; int rvcount = -1; if (args.scriptHash != null) { scriptHash = UInt160.Parse((string)args.scriptHash); } if (args.initialPosition != null) { initialPosition = (int)args.initialPosition; } if (args.rvcount != null) { rvcount = (int)args.rvcount; } return(this._loadScript(script, flags, scriptHash, rvcount, initialPosition)); case EngineMethod.loadcontract: UInt160 contractHash = new UInt160((byte[])args.hash); string contractMethod = (string)args.method; CallFlags contractFlags = (CallFlags)((byte)args.flags); int pcount = (int)args.pcount; return(this._loadContract(contractHash, contractMethod, pcount, contractFlags)); case EngineMethod.getvmstate: return(this._getVMState()); case EngineMethod.getresultstack: return(this._getResultStack()); case EngineMethod.gettrigger: return(this._getTrigger()); case EngineMethod.getgasconsumed: return(this._getGasConsumed()); case EngineMethod.getnotifications: return(this._getNotifications()); case EngineMethod.getlogs: return(this._getLogs()); case EngineMethod.getfaultexception: return(this._getFaultException()); case EngineMethod.dispose_engine: this.disposeEngine(); return(true); case EngineMethod.push: return(this._push((string)args.item)); default: throw new InvalidOperationException(); } }
private dynamic dispatchEngineMethod(EngineMethod method, dynamic args) { switch (method) { case EngineMethod.create: TriggerType trigger = (TriggerType)args.trigger; long gas = long.Parse((string)args.gas); IVerifiable container = null; if (args.container != null) { container = deserializeContainer(args.container); } return(this._create(trigger, container, this.selectSnapshot(args.snapshot, false), gas)); case EngineMethod.execute: return(this._execute()); case EngineMethod.loadscript: Script script = new Script((byte[])args.script); CallFlags flags = (CallFlags)((byte)args.flags); UInt160 scriptHash = null; int initialPosition = 0; if (args.scriptHash != null) { scriptHash = UInt160.Parse((string)args.scriptHash); } if (args.initialPosition != null) { initialPosition = (int)args.initialPosition; } return(this._loadScript(script, flags, scriptHash, initialPosition)); case EngineMethod.loadcontract: UInt160 contractHash = new UInt160((byte[])args.hash); string contractMethod = (string)args.method; CallFlags contractFlags = (CallFlags)((byte)args.flags); bool packParameters = (bool)args.packParameters; return(this._loadContract(contractHash, contractMethod, contractFlags, packParameters)); case EngineMethod.getvmstate: return(this._getVMState()); case EngineMethod.getresultstack: return(this._getResultStack()); case EngineMethod.gettrigger: return(this._getTrigger()); case EngineMethod.getgasconsumed: return(this._getGasConsumed()); case EngineMethod.getnotifications: return(this._getNotifications()); case EngineMethod.getlogs: return(this._getLogs()); case EngineMethod.dispose_engine: this.disposeEngine(); return(true); default: throw new InvalidOperationException(); } }