Simplified buildHeightMessage()

This commit is contained in:
CalDescent 2022-05-30 14:38:05 +02:00
parent 16ba426932
commit 958fb299b2

View File

@ -1166,23 +1166,15 @@ public class Network {
final long HEIGHT_V3_PEER_VERSION = 0x0300030003L; final long HEIGHT_V3_PEER_VERSION = 0x0300030003L;
if (peer.getPeersVersion() >= HEIGHT_V3_PEER_VERSION) { if (peer.getPeersVersion() >= HEIGHT_V3_PEER_VERSION) {
return Network.getInstance().buildHeightV3Message(peer, blockData); // HEIGHT_V3 contains even more useful info
return new HeightV3Message(blockData.getHeight(), blockData.getSignature(), blockData.getReference(),
blockData.getTimestamp(), blockData.getMinterPublicKey(), blockData.getOnlineAccountsCount(),
blockData.getTransactionCount());
} else { } else {
return Network.getInstance().buildHeightV2Message(peer, blockData); return new HeightV2Message(blockData.getHeight(), blockData.getSignature(),
blockData.getTimestamp(), blockData.getMinterPublicKey());
} }
} }
private Message buildHeightV2Message(Peer peer, BlockData blockData) {
// HEIGHT_V2 contains way more useful info
return new HeightV2Message(blockData.getHeight(), blockData.getSignature(),
blockData.getTimestamp(), blockData.getMinterPublicKey());
}
private Message buildHeightV3Message(Peer peer, BlockData blockData) {
// HEIGHT_V3 contains even more useful info
return new HeightV3Message(blockData.getHeight(), blockData.getSignature(), blockData.getReference(),
blockData.getTimestamp(), blockData.getMinterPublicKey(), blockData.getOnlineAccountsCount(),
blockData.getTransactionCount());
}
public Message buildNewTransactionMessage(Peer peer, TransactionData transactionData) { public Message buildNewTransactionMessage(Peer peer, TransactionData transactionData) {
// In V2 we send out transaction signature only and peers can decide whether to request the full transaction // In V2 we send out transaction signature only and peers can decide whether to request the full transaction