Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
textDecoder: new TextDecoder
});
const trx_id_arr = hexToUint8Array(trx_id);
sb_action.pushName(action.act.account);
sb_action.pushName(action.act.name);
sb_action.pushBytes(action.act.data);
if (this.amq) {
// this.logger.info(`Queueing action for ${action.act.account}::${action.act.name}`);
const block_buffer = new Int64(block_num).toBuffer();
const timestamp_buffer = this.int32ToBuffer(block_timestamp.getTime() / 1000);
const trx_id_buffer = Buffer.from(trx_id_arr);
const recv_buffer = new Int64(action.receipt[1].recv_sequence).toBuffer();
const global_buffer = new Int64(action.receipt[1].global_sequence).toBuffer();
const action_buffer = Buffer.from(sb_action.array);
// this.logger.info(`Publishing action`)
this.amq.send('action', Buffer.concat([block_buffer, timestamp_buffer, trx_id_buffer, recv_buffer, global_buffer, action_buffer]))
} else {
console.error(`No queue when processing action for ${action.act.account}::${action.act.name} in ${trx_id}`, {action});
}
}
if (action.inline_traces && action.inline_traces.length) {
for (let itc of action.inline_traces) {
// this.logger.info("inline trace\n", itc);
if (itc[0] === 'action_trace_v0') {
this.queueAction(block_num, itc[1], trx_id, block_timestamp);
}
}
// outPacket.writeUInt32(this.userId)
// should always be 0xFFFFFFFF for a full update
outPacket.writeUInt32(0xFFFFFFFF) // flags
// flag & 0x1
outPacket.writeUInt64(new Uint64LE(0x2241158F)) // unk00, nexon id?
// end flag & 0x1
// flag & 0x2
outPacket.writeString(new PacketString(user.playerName)) // userName
// end of flag & 0x2
// flag & 0x4
outPacket.writeUInt16(user.level) // level
// end of flag & 0x4
// flag & 0x8
outPacket.writeUInt64(new Uint64LE(user.curExp)) // curExp
outPacket.writeUInt64(new Uint64LE(user.maxExp)) // maxExp
outPacket.writeUInt32(0x313) // unk03
// end of flag & 0x8
// flag & 0x10
outPacket.writeUInt8(user.rank) // rank
outPacket.writeUInt8(0) // unk05
// end of flag & 0x10
// flag & 0x20
outPacket.writeUInt64(new Uint64LE(0x7AF3)) // unk06
// end of flag & 0x20
// flag & 0x40
outPacket.writeUInt32(10) // unk07
outPacket.writeUInt32(user.wins) // wins
outPacket.writeUInt32(user.kills) // kills
outPacket.writeUInt32(80) // unk10
outPacket.writeUInt32(user.deaths) // deaths
// should always be 0xFFFFFFFF for a full update
outPacket.writeUInt32(0xFFFFFFFF) // flags
// flag & 0x1
outPacket.writeUInt64(new Uint64LE(0x2241158F)) // unk00, nexon id?
// end flag & 0x1
// flag & 0x2
outPacket.writeString(new PacketString(user.playerName)) // userName
// end of flag & 0x2
// flag & 0x4
outPacket.writeUInt16(user.level) // level
// end of flag & 0x4
// flag & 0x8
outPacket.writeUInt64(new Uint64LE(user.curExp)) // curExp
outPacket.writeUInt64(new Uint64LE(user.maxExp)) // maxExp
outPacket.writeUInt32(0x313) // unk03
// end of flag & 0x8
// flag & 0x10
outPacket.writeUInt8(user.rank) // rank
outPacket.writeUInt8(0) // unk05
// end of flag & 0x10
// flag & 0x20
outPacket.writeUInt64(new Uint64LE(0x7AF3)) // unk06
// end of flag & 0x20
// flag & 0x40
outPacket.writeUInt32(10) // unk07
outPacket.writeUInt32(user.wins) // wins
outPacket.writeUInt32(user.kills) // kills
outPacket.writeUInt32(80) // unk10
outPacket.writeUInt32(user.deaths) // deaths
outPacket.writeUInt32(user.assists) // assists
function buildHeader(type, sector) {
const u8 = new Uint8Array(16);
const view = new DataView(u8.buffer);
view.setUint32(0, type, true);
view.setUint32(4, 0, true); // priority: low
u8.set((new Uint64LE(sector)).toArray(), 8);
return u8;
}
public static build(outPacket: OutPacketBase): void {
outPacket.writeUInt8(0) // unk00
outPacket.writeUInt8(0) // unk01
outPacket.writeUInt8(0) // unk02
outPacket.writeUInt64(new Uint64LE(0)) // unk03
outPacket.writeUInt64(new Uint64LE(0)) // unk04
outPacket.writeUInt8(0) // unk05
outPacket.writeString(new PacketString(null)) // unk06
outPacket.writeString(new PacketString(null)) // unk07
outPacket.writeUInt8(0) // unk08
outPacket.writeUInt8(0) // unk09
}
}
outPacket.writeUInt16(this.room.settings.startMoney) // startMoney
// end flags & 0x20000
// flags & 0x40000
outPacket.writeUInt8(0) // unk26
// end flags & 0x40000
// flags & 0x80000
outPacket.writeUInt8(0) // unk27
// end flags & 0x80000
// flags & 0x100000
outPacket.writeUInt8(0) // unk28
// end flags & 0x100000
// flags & 0x200000
outPacket.writeUInt8(1) // unk29
// end flags & 0x200000
// flags & 0x400000
outPacket.writeUInt64(new Uint64LE(0x5AF6F7BF)) // unk30
// end flags & 0x400000
// flags & 0x800000
outPacket.writeUInt8(this.room.settings.winLimit) // winLimit
outPacket.writeUInt16(this.room.settings.killLimit) // killLimit
outPacket.writeUInt8(this.room.settings.forceCamera) // forceCamera
// end flags & 0x800000
// flags & 0x1000000
outPacket.writeUInt8(4) // unk31
// end flags & 0x1000000
// flags & 0x2000000
outPacket.writeUInt8(0) // unk35
// end flags & 0x2000000
// flags & 0x4000000
outPacket.writeUInt8(this.room.settings.nextMapEnabled) // nextMapEnabled
// end flags & 0x4000000
// flags & 0x8000000
public static async build(room: Room, outPacket: OutPacketBase): Promise {
outPacket.writeUInt32(room.host.userId) // roomHostId
outPacket.writeUInt8(2) // unk01
outPacket.writeUInt8(2) // unk02
outPacket.writeUInt16(room.id) // roomId
outPacket.writeUInt8(5) // unk04
// special class start?
// flags & 0x1
outPacket.writeUInt64(new Uint64LE('FFFFFFFFFFFFFFFF', 16)) // roomFlags
outPacket.writeString(new PacketString(room.settings.roomName)) // roomName
// end of flags & 0x1
// flags & 0x2
outPacket.writeUInt8(0) // unk05
// end of flags & 0x2
// flags & 0x4
outPacket.writeUInt8(0) // unk06
outPacket.writeUInt32(0) // unk07
outPacket.writeUInt32(0) // unk08
// end of flags & 0x4
// flags & 0x8
outPacket.writeString(new PacketString(null)) // unk09
// end of flags & 0x8
// flags & 0x10
outPacket.writeUInt16(0) // unk10
// end of flags & 0x10
async processContractRow(job) {
const sb = new Serialize.SerialBuffer({
textEncoder: new TextEncoder,
textDecoder: new TextDecoder,
array: new Uint8Array(job.content)
});
const block_num = new Int64(sb.getUint8Array(8)).toString();
const present = sb.get();
const block_timestamp_arr = sb.getUint8Array(4);
// const block_timestamp_int = sb.getUint32();
let buffer = Buffer.from(block_timestamp_arr);
var block_timestamp_int = buffer.readUInt32BE(0);
const block_timestamp = new Date(block_timestamp_int * 1000);
sb.get(); // version
const code = sb.getName();
const scope = sb.getName();
const table = sb.getName();
const primary_key = new Int64(sb.getUint8Array(8)).toString();
const payer = sb.getName();
const data_raw = sb.getBytes();
try {
const table_type = await this.delta_handler.getTableType(code, table);
return new Promise((resolve, reject) => {
const ts = Math.floor(block_timestamp.getTime() / 1000);
// this.logger.info('ts', ts);
const timestamp_buffer = this.int32ToBuffer(ts);
const block_buffer = new Int64(block_num).toBuffer();
const present_buffer = Buffer.from([row.present]);
// this.logger.info(`Publishing ${name}`)
this.amq.send(name, Buffer.concat([block_buffer, present_buffer, timestamp_buffer, Buffer.from(row.data)]))
.then(resolve)
.catch(reject)
})
async processBlockRange(job) {
this.job = job;
//await this.amq.ack(job)
const start_buffer = job.content.slice(0, 8);
const end_buffer = job.content.slice(8);
const start_block = new Int64BE(start_buffer).toString();
const end_block = new Int64BE(end_buffer).toString();
this.logger.info(`processBlockRange pid : ${process.pid} ${start_block} to ${end_block}`);
const dac_directory = new DacDirectory({config: this.config, db:this.db});
await dac_directory.reload();
const action_handler = new ActionHandler({queue: this.amq, config: this.config, dac_directory, logger:this.logger});
const block_handler = new TraceHandler({queue: this.amq, action_handler, config: this.config, logger:this.logger});
const delta_handler = new DeltaHandler({queue: this.amq, config: this.config, dac_directory, logger:this.logger});
this.br = new StateReceiver({startBlock: start_block, endBlock: end_block, mode: 1, config: this.config});
this.br.registerDeltaHandler(delta_handler);
this.br.registerTraceHandler(block_handler);
this.br.registerDoneHandler(() => {
// this.logger.info(`StateReceiver completed`, job)