UDP Circuit basics, message changes
This commit is contained in:
177
lib/classes/messages/GroupActiveProposalItemReply.ts
Normal file
177
lib/classes/messages/GroupActiveProposalItemReply.ts
Normal file
@@ -0,0 +1,177 @@
|
||||
// This file has been automatically generated by writeMessageClasses.js
|
||||
|
||||
import {UUID} from '../UUID';
|
||||
import {MessageFlags} from '../../enums/MessageFlags';
|
||||
import {MessageBase} from '../MessageBase';
|
||||
import {Message} from '../../enums/Message';
|
||||
|
||||
export class GroupActiveProposalItemReplyMessage implements MessageBase
|
||||
{
|
||||
name = 'GroupActiveProposalItemReply';
|
||||
messageFlags = MessageFlags.Trusted | MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
|
||||
id = Message.GroupActiveProposalItemReply;
|
||||
|
||||
AgentData: {
|
||||
AgentID: UUID;
|
||||
GroupID: UUID;
|
||||
};
|
||||
TransactionData: {
|
||||
TransactionID: UUID;
|
||||
TotalNumItems: number;
|
||||
};
|
||||
ProposalData: {
|
||||
VoteID: UUID;
|
||||
VoteInitiator: UUID;
|
||||
TerseDateID: string;
|
||||
StartDateTime: string;
|
||||
EndDateTime: string;
|
||||
AlreadyVoted: boolean;
|
||||
VoteCast: string;
|
||||
Majority: number;
|
||||
Quorum: number;
|
||||
ProposalText: string;
|
||||
}[];
|
||||
|
||||
getSize(): number
|
||||
{
|
||||
return ((this.calculateVarVarSize(this.ProposalData, 'TerseDateID', 1) + this.calculateVarVarSize(this.ProposalData, 'StartDateTime', 1) + this.calculateVarVarSize(this.ProposalData, 'EndDateTime', 1) + this.calculateVarVarSize(this.ProposalData, 'VoteCast', 1) + this.calculateVarVarSize(this.ProposalData, 'ProposalText', 1) + 41) * this.ProposalData.length) + 53;
|
||||
}
|
||||
|
||||
calculateVarVarSize(block: object[], paramName: string, extraPerVar: number): number
|
||||
{
|
||||
let size = 0;
|
||||
block.forEach((bl: any) =>
|
||||
{
|
||||
size += bl[paramName].length + extraPerVar;
|
||||
});
|
||||
return size;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.AgentData['AgentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData['GroupID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.TransactionData['TransactionID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt32LE(this.TransactionData['TotalNumItems'], pos);
|
||||
pos += 4;
|
||||
const count = this.ProposalData.length;
|
||||
buf.writeUInt8(this.ProposalData.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.ProposalData[i]['VoteID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.ProposalData[i]['VoteInitiator'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8(this.ProposalData[i]['TerseDateID'].length, pos++);
|
||||
buf.write(this.ProposalData[i]['TerseDateID'], pos);
|
||||
pos += this.ProposalData[i]['TerseDateID'].length;
|
||||
buf.writeUInt8(this.ProposalData[i]['StartDateTime'].length, pos++);
|
||||
buf.write(this.ProposalData[i]['StartDateTime'], pos);
|
||||
pos += this.ProposalData[i]['StartDateTime'].length;
|
||||
buf.writeUInt8(this.ProposalData[i]['EndDateTime'].length, pos++);
|
||||
buf.write(this.ProposalData[i]['EndDateTime'], pos);
|
||||
pos += this.ProposalData[i]['EndDateTime'].length;
|
||||
buf.writeUInt8((this.ProposalData[i]['AlreadyVoted']) ? 1 : 0, pos++);
|
||||
buf.writeUInt8(this.ProposalData[i]['VoteCast'].length, pos++);
|
||||
buf.write(this.ProposalData[i]['VoteCast'], pos);
|
||||
pos += this.ProposalData[i]['VoteCast'].length;
|
||||
buf.writeFloatLE(this.ProposalData[i]['Majority'], pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.ProposalData[i]['Quorum'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt8(this.ProposalData[i]['ProposalText'].length, pos++);
|
||||
buf.write(this.ProposalData[i]['ProposalText'], pos);
|
||||
pos += this.ProposalData[i]['ProposalText'].length;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
let varLength = 0;
|
||||
const newObjAgentData: {
|
||||
AgentID: UUID,
|
||||
GroupID: UUID
|
||||
} = {
|
||||
AgentID: UUID.zero(),
|
||||
GroupID: UUID.zero()
|
||||
};
|
||||
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentData['GroupID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.AgentData = newObjAgentData;
|
||||
const newObjTransactionData: {
|
||||
TransactionID: UUID,
|
||||
TotalNumItems: number
|
||||
} = {
|
||||
TransactionID: UUID.zero(),
|
||||
TotalNumItems: 0
|
||||
};
|
||||
newObjTransactionData['TransactionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjTransactionData['TotalNumItems'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
this.TransactionData = newObjTransactionData;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.ProposalData = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjProposalData: {
|
||||
VoteID: UUID,
|
||||
VoteInitiator: UUID,
|
||||
TerseDateID: string,
|
||||
StartDateTime: string,
|
||||
EndDateTime: string,
|
||||
AlreadyVoted: boolean,
|
||||
VoteCast: string,
|
||||
Majority: number,
|
||||
Quorum: number,
|
||||
ProposalText: string
|
||||
} = {
|
||||
VoteID: UUID.zero(),
|
||||
VoteInitiator: UUID.zero(),
|
||||
TerseDateID: '',
|
||||
StartDateTime: '',
|
||||
EndDateTime: '',
|
||||
AlreadyVoted: false,
|
||||
VoteCast: '',
|
||||
Majority: 0,
|
||||
Quorum: 0,
|
||||
ProposalText: ''
|
||||
};
|
||||
newObjProposalData['VoteID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjProposalData['VoteInitiator'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
varLength = buf.readUInt8(pos++);
|
||||
newObjProposalData['TerseDateID'] = buf.toString('utf8', pos, pos + (varLength - 1));
|
||||
pos += varLength;
|
||||
varLength = buf.readUInt8(pos++);
|
||||
newObjProposalData['StartDateTime'] = buf.toString('utf8', pos, pos + (varLength - 1));
|
||||
pos += varLength;
|
||||
varLength = buf.readUInt8(pos++);
|
||||
newObjProposalData['EndDateTime'] = buf.toString('utf8', pos, pos + (varLength - 1));
|
||||
pos += varLength;
|
||||
newObjProposalData['AlreadyVoted'] = (buf.readUInt8(pos++) === 1);
|
||||
varLength = buf.readUInt8(pos++);
|
||||
newObjProposalData['VoteCast'] = buf.toString('utf8', pos, pos + (varLength - 1));
|
||||
pos += varLength;
|
||||
newObjProposalData['Majority'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjProposalData['Quorum'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
varLength = buf.readUInt8(pos++);
|
||||
newObjProposalData['ProposalText'] = buf.toString('utf8', pos, pos + (varLength - 1));
|
||||
pos += varLength;
|
||||
this.ProposalData.push(newObjProposalData);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user