public void writeUint48(long time) throws IOException { byte[] bytes = SerializeUtils.uint48ToBytes(time); this.write(bytes); } }
public double readDouble() throws NulsException { byte[] bytes = this.readBytes(8); if (null == bytes) { return 0; } return SerializeUtils.bytes2Double(bytes); }
public short readShort() throws NulsException { byte[] bytes = this.readBytes(2); if (null == bytes) { return 0; } return SerializeUtils.bytes2Short(bytes); }
@Override public void parse(NulsByteBuffer byteBuffer) throws NulsException { this.type = byteBuffer.readByte(); this.address = byteBuffer.readBytes(Address.ADDRESS_LENGTH); this.time = byteBuffer.readUint48(); this.height = byteBuffer.readVarInt(); this.roundIndex = byteBuffer.readVarInt(); this.reasonCode = byteBuffer.readShort(); this.evidence = byteBuffer.readByLengthByte(); }
@Override public int size() { int size = SerializeUtils.sizeOfNulsData(hash); size += Address.ADDRESS_LENGTH * 3; size += SerializeUtils.sizeOfInt64(); size += SerializeUtils.sizeOfDouble(commissionRate); size += SerializeUtils.sizeOfUint48(); size += SerializeUtils.sizeOfVarInt(blockHeight); size += SerializeUtils.sizeOfVarInt(delHeight); return size; }
@Override public int size() { int size = 0; size += SerializeUtils.sizeOfUint32(); // roundIndex size += SerializeUtils.sizeOfUint16(); // consensusMemberCount size += SerializeUtils.sizeOfUint48(); //roundStartTime size += SerializeUtils.sizeOfUint16(); // packingIndexOfRound return size; }
@Override protected void serializeToStream(NulsOutputStreamBuffer buffer) throws IOException { buffer.write(digestAlgType); buffer.writeBytesWithLength(digestBytes); }
@Override public void parse(NulsByteBuffer byteBuffer) throws NulsException { this.roundIndex = byteBuffer.readUint32(); this.consensusMemberCount = byteBuffer.readUint16(); this.roundStartTime = byteBuffer.readUint48(); this.packingIndexOfRound = byteBuffer.readUint16(); } }
@Override public boolean argsValidate(String[] args) { int length = args.length; if (length < 2 || length > 3) { return false; } if (!CommandHelper.checkArgsIsNull(args)) { return false; } if (!AddressTool.validAddress(args[1])) { return false; } return true; }
public String getAddressStr() { if (addressStr == null) { addressStr = AddressTool.getStringAddressByBytes(address); } return addressStr; }
@Override public int size() { int s = 0; s += SerializeUtils.sizeOfUint16(); // severPort s += SerializeUtils.sizeOfString(nodeIp); return s; }
/** * serialize important field */ @Override protected void serializeToStream(NulsOutputStreamBuffer stream) throws IOException { stream.writeNulsData(this.joinTxHash); }
@Override public int size() { int size = 0; size += SerializeUtils.sizeOfNulsData(startHash); size += SerializeUtils.sizeOfNulsData(endHash); return size; }
@Override public void parse(NulsByteBuffer byteBuffer) throws NulsException { startHeight = byteBuffer.readUint32(); endHeight = byteBuffer.readUint32(); }
public static byte[] uint48ToBytes(long val) { byte[] bytes = new byte[SerializeUtils.sizeOfUint48()]; bytes[0] = (byte) (0xFF & val); bytes[1] = (byte) (0xFF & (val >> 8)); bytes[2] = (byte) (0xFF & (val >> 16)); bytes[3] = (byte) (0xFF & (val >> 24)); bytes[4] = (byte) (0xFF & (val >> 32)); bytes[5] = (byte) (0xFF & (val >> 40)); return bytes; }
@Override public boolean argsValidate(String[] args) { if (args.length != 2) { return false; } if (!CommandHelper.checkArgsIsNull(args)) { return false; } return true; }
/** * Constructs a new VarInt with the given unsigned long value. * * @param value the unsigned long value (beware widening conversion of negatives!) */ public VarInt(long value) { this.value = value; originallyEncodedSize = getSizeInBytes(); }
@Override public boolean argsValidate(String[] args) { int length = args.length; if(length != 2) { return false; } if (!CommandHelper.checkArgsIsNull(args)) { return false; } if (!AddressTool.validAddress(args[1])) { return false; } return true; }
@Override public int size() { int size = 1 + publicKey.length; size += SerializeUtils.sizeOfNulsData(signData); return size; }
@Override public int size() { int size = 1; size += SerializeUtils.sizeOfNulsData(hash); return size; }