Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
fix TRANSACTION_PACKET_SIZE assignment to TCP (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
alon-e authored and GalRogozinski committed Apr 18, 2018
1 parent 16e5a34 commit a3a1aa8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/iota/iri/Iota.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Iota(Configuration configuration) {
int numKeysMilestone = configuration.integer(Configuration.DefaultConfSettings.NUMBER_OF_KEYS_IN_A_MILESTONE);
boolean dontValidateMilestoneSig = configuration.booling(Configuration.DefaultConfSettings
.DONT_VALIDATE_TESTNET_MILESTONE_SIG);
int reqHashSize = configuration.integer(Configuration.DefaultConfSettings.REQUEST_HASH_SIZE);
int transactionPacketSize = configuration.integer(Configuration.DefaultConfSettings.TRANSACTION_PACKET_SIZE);

maxTipSearchDepth = configuration.integer(Configuration.DefaultConfSettings.MAX_DEPTH);
if(testnet) {
Expand Down Expand Up @@ -93,7 +93,7 @@ public Iota(Configuration configuration) {
milestone = new Milestone(tangle, coordinator, initialSnapshot, transactionValidator, testnet, messageQ,
numKeysMilestone, milestoneStartIndex, dontValidateMilestoneSig);
node = new Node(configuration, tangle, transactionValidator, transactionRequester, tipsViewModel, milestone, messageQ);
replicator = new Replicator(node, tcpPort, maxPeers, testnet, reqHashSize);
replicator = new Replicator(node, tcpPort, maxPeers, testnet, transactionPacketSize);
udpReceiver = new UDPReceiver(udpPort, node, configuration.integer(Configuration.DefaultConfSettings.TRANSACTION_PACKET_SIZE));
ledgerValidator = new LedgerValidator(tangle, milestone, transactionRequester, messageQ);
tipsManager = new TipsManager(tangle, ledgerValidator, transactionValidator, tipsViewModel, milestone,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/iota/iri/network/replicator/Replicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class Replicator {
private final int port;
private ReplicatorSourcePool replicatorSourcePool;

public Replicator(final Node node, int port, final int maxPeers, final boolean testnet, int reqHashSize) {
public Replicator(final Node node, int port, final int maxPeers, final boolean testnet, int transactionPacketSize) {
this.port = port;
replicatorSinkPool = new ReplicatorSinkPool(node, port, reqHashSize);
replicatorSinkPool = new ReplicatorSinkPool(node, port, transactionPacketSize);
replicatorSourcePool = new ReplicatorSourcePool(replicatorSinkPool, node, maxPeers, testnet);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ReplicatorSinkPool implements Runnable {

private static final Logger log = LoggerFactory.getLogger(ReplicatorSinkPool.class);
private final int port;
private int reqHashSize;
private int transactionPacketSize;
private final Node node;

private ExecutorService sinkPool;
Expand All @@ -27,10 +27,10 @@ public class ReplicatorSinkPool implements Runnable {

public final static int PORT_BYTES = 10;

public ReplicatorSinkPool(Node node, int port, int reqHashSize) {
public ReplicatorSinkPool(Node node, int port, int transactionPacketSize) {
this.node = node;
this.port = port;
this.reqHashSize = reqHashSize;
this.transactionPacketSize = transactionPacketSize;
}

@Override
Expand Down Expand Up @@ -70,7 +70,7 @@ public void run() {
}

public void createSink(TCPNeighbor neighbor) {
Runnable proc = new ReplicatorSinkProcessor( neighbor, this, port, reqHashSize);
Runnable proc = new ReplicatorSinkProcessor( neighbor, this, port, transactionPacketSize);
sinkPool.submit(proc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iota.iri.network.Node;

class ReplicatorSinkProcessor implements Runnable {

private static final Logger log = LoggerFactory.getLogger(ReplicatorSinkProcessor.class);
Expand All @@ -22,15 +20,15 @@ class ReplicatorSinkProcessor implements Runnable {
public final static int CRC32_BYTES = 16;
private final ReplicatorSinkPool replicatorSinkPool;
private final int port;
private int reqHashSize;
private int transactionPacketSize;

public ReplicatorSinkProcessor(final TCPNeighbor neighbor,
final ReplicatorSinkPool replicatorSinkPool,
final int port, int reqHashSize) {
final int port, int transactionPacketSize) {
this.neighbor = neighbor;
this.replicatorSinkPool = replicatorSinkPool;
this.port = port;
this.reqHashSize = reqHashSize;
this.transactionPacketSize = transactionPacketSize;
}

@Override
Expand Down Expand Up @@ -89,7 +87,7 @@ public void run() {

byte[] bytes = message.array();

if (bytes.length == reqHashSize) {
if (bytes.length == transactionPacketSize) {
try {
CRC32 crc32 = new CRC32();
crc32.update(message.array());
Expand Down

0 comments on commit a3a1aa8

Please sign in to comment.