const { v4: uuidv4 } = require('uuid');

class ValidatorVote {
  constructor({
    blockId,
    blockHeight,
    blockHash,
    validatorNodeId,
    vote,
    reason,
    signature,
    metadata
  } = {}) {
    this.id = uuidv4();
    this.blockId = blockId || null;
    this.blockHeight = Number(blockHeight || 0);
    this.blockHash = blockHash || null;
    this.validatorNodeId = validatorNodeId || null;
    this.vote = vote === 'reject' ? 'reject' : 'approve';
    this.reason = reason || '';
    this.signature = signature || null;
    this.metadata = metadata || {};
    this.createdAt = new Date().toISOString();
  }
}

module.exports = ValidatorVote;
