private dynamic dispatchSnapshotMethod(SnapshotMethod method, dynamic args) { switch (method) { case SnapshotMethod.snapshot_clone: return(this._snapshotClone()); case SnapshotMethod.snapshot_get_change_set: return(this._snapshotGetChangeSet(this.selectSnapshot(args.snapshot, true))); case SnapshotMethod.snapshot_commit: this._snapshotCommit(this.selectSnapshot(args.snapshot)); return(true); case SnapshotMethod.snapshot_reset: this.resetSnapshots(); return(true); default: throw new InvalidOperationException(); } }
private dynamic dispatchSnapshotMethod(SnapshotMethod method, dynamic args) { switch (method) { case SnapshotMethod.snapshot_blocks_add: UInt256 blockHash = new UInt256((byte[])args.hash); byte[] blockSerialized = (byte[])args.block; Block block = new Block(); using (MemoryStream ms = new MemoryStream(blockSerialized)) using (BinaryReader reader = new BinaryReader(ms)) { block.Deserialize(reader); } return(this._snapshotBlocksAdd(this.selectSnapshot(args.snapshot), blockHash, block)); case SnapshotMethod.snapshot_transactions_add: uint blockIndex = (uint)args.index; byte[] txSerialized = (byte[])args.tx; VMState vmState = (VMState)args.state; Transaction tx = new Transaction(); using (MemoryStream ms = new MemoryStream(txSerialized)) using (BinaryReader reader = new BinaryReader(ms)) { ((IVerifiable)tx).Deserialize(reader); } return(this._snapshotTransactionsAdd(this.selectSnapshot(args.snapshot), tx, blockIndex, vmState)); case SnapshotMethod.snapshot_transactions_delete: UInt256 transactionHash = new UInt256((byte[])args.hash); return(this._snapshotTransactionsDelete(this.selectSnapshot(args.snapshot), transactionHash)); case SnapshotMethod.snapshot_clone: return(this._snapshotClone()); case SnapshotMethod.snapshot_change_block_hash_index: uint bIndex = (uint)args.index; UInt256 blockChangeHash = new UInt256((byte[])args.hash); return(this._snapshotChangeBlockHashIndex(this.selectSnapshot(args.snapshot), bIndex, blockChangeHash)); case SnapshotMethod.snapshot_change_header_hash_index: uint hIndex = (uint)args.index; UInt256 headerChangeHash = new UInt256((byte[])args.hash); return(this._snapshotChangeHeaderHashIndex(this.selectSnapshot(args.snapshot), hIndex, headerChangeHash)); case SnapshotMethod.snapshot_get_change_set: return(this._snapshotGetChangeSet(this.selectSnapshot(args.snapshot, true))); case SnapshotMethod.snapshot_commit: this._snapshotCommit( this.selectSnapshot(args.snapshot), args.partial ); return(true); case SnapshotMethod.snapshot_set_persisting_block: byte[] persistingBlockSerialized = (byte[])args.block; Block persisting = new Block(); using (MemoryStream ms = new MemoryStream(persistingBlockSerialized)) using (BinaryReader reader = new BinaryReader(ms)) { persisting.Deserialize(reader); } this.selectSnapshot(args.snapshot).PersistingBlock = persisting; return(true); case SnapshotMethod.snapshot_has_persisting_block: return(this.selectSnapshot(args.snapshot).PersistingBlock != null); case SnapshotMethod.snapshot_reset: this.resetSnapshots(); return(true); default: throw new InvalidOperationException(); } }