/* eslint-disable prefer-const */'use strict'const fbe = require('../proto/fbe')const proto = require('../proto/proto')// Create a new account with some orderslet account = new proto.Account(1, 'Test', proto.State.good, new proto.Balance('USD', 1000.0), new proto.Balance('EUR', 100.0))account.orders.push(new proto.Order(1, 'EURUSD', proto.OrderSide.buy, proto.OrderType.market, 1.23456, 1000.0))account.orders.push(new proto.Order(2, 'EURUSD', proto.OrderSide.sell, proto.OrderType.limit, 1.0, 100.0))account.orders.push(new proto.Order(3, 'EURUSD', proto.OrderSide.buy, proto.OrderType.stop, 1.5, 10.0))// Serialize the account to the FBE streamlet writer = new proto.AccountFinalModel(new fbe.WriteBuffer())writer.serialize(account)console.assert(writer.verify())// Show the serialized FBE sizeconsole.log(`FBE size: ${writer.buffer.size}`)// Deserialize the account from the FBE streamlet reader = new proto.AccountFinalModel(new fbe.ReadBuffer())reader.attachBuffer(writer.buffer)console.assert(reader.verify())reader.deserialize(account)// Show account contentconsole.log()console.log(account)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。