Skip to main content
deleted 25 characters in body
Source Link
int processed = 0, dropped = 0;

int processed = 0, dropped = 0;

processor.submit(() -> node.preProcessReceivedData(bytes, address, "udp"));

processor.submit(() -> node.preProcessReceivedData(bytes, address, "udp"));

existingNeighbor = false; List neighbors = node.getNeighbors(); neighbors.stream().filter(n -> n instanceof TCPNeighbor) .map(n -> ((TCPNeighbor) n)) .forEach(n -> { String hisAddress = inet_socket_address.getAddress().getHostAddress(); if (n.getHostAddress().equals(hisAddress)) { existingNeighbor = true; neighbor = n; } } );

existingNeighbor = false; List neighbors = node.getNeighbors(); neighbors.stream().filter(n -> n instanceof TCPNeighbor) .map(n -> ((TCPNeighbor) n)) .forEach(n -> { String hisAddress = inet_socket_address.getAddress().getHostAddress(); if (n.getHostAddress().equals(hisAddress)) { existingNeighbor = true; neighbor = n; } } );

final TCPNeighbor fresh_neighbor = new TCPNeighbor(inet_socket_address,false); node.getNeighbors().add(fresh_neighbor); neighbor = fresh_neighbor; Neighbor.incNumPeers();

final TCPNeighbor fresh_neighbor = new TCPNeighbor(inet_socket_address,false); node.getNeighbors().add(fresh_neighbor); neighbor = fresh_neighbor; Neighbor.incNumPeers();

offset = 0; while (((count = stream.read(data, offset, ReplicatorSinkPool.PORT_BYTES - offset)) != -1) && (offset

Thread exit, if the first 10 bytes of the payload received is not the listener service port or connection is closed. The port value received will be used by the ReplicatorSinkProcessor thread to send information back to peer.

The final section of this thread focuses on ensuring proper payload was sent. The full payload in proper order is 10 bytes (peer listener port), 1650 bytes (main payload), and 16 bytes (checksum). The data received is unpacked, checksum validated for main payload, and then submitted to com.iota.iri.network.Node::preProcessReceivedData method for processing.

if (!crcError) { node.preProcessReceivedData(data, address, "tcp"); }

offset = 0; while (((count = stream.read(data, offset, ReplicatorSinkPool.PORT_BYTES - offset)) != -1) && (offset < ReplicatorSinkPool.PORT_BYTES)) { offset += count; }

Thread exit, if the first 10 bytes of the payload received is not the listener service port or connection is closed. The port value received will be used by the ReplicatorSinkProcessor thread to send information back to peer.

The final section of this thread focuses on ensuring proper payload was sent. The full payload in proper order is 10 bytes (peer listener port), 1650 bytes (main payload), and 16 bytes (checksum). The data received is unpacked, checksum validated for main payload, and then submitted to com.iota.iri.network.Node::preProcessReceivedData method for processing.

if (!crcError) { node.preProcessReceivedData(data, address, "tcp"); }

int processed = 0, dropped = 0;
processor.submit(() -> node.preProcessReceivedData(bytes, address, "udp"));
existingNeighbor = false; List neighbors = node.getNeighbors(); neighbors.stream().filter(n -> n instanceof TCPNeighbor) .map(n -> ((TCPNeighbor) n)) .forEach(n -> { String hisAddress = inet_socket_address.getAddress().getHostAddress(); if (n.getHostAddress().equals(hisAddress)) { existingNeighbor = true; neighbor = n; } } );
final TCPNeighbor fresh_neighbor = new TCPNeighbor(inet_socket_address,false); node.getNeighbors().add(fresh_neighbor); neighbor = fresh_neighbor; Neighbor.incNumPeers();
offset = 0; while (((count = stream.read(data, offset, ReplicatorSinkPool.PORT_BYTES - offset)) != -1) && (offset

Thread exit, if the first 10 bytes of the payload received is not the listener service port or connection is closed. The port value received will be used by the ReplicatorSinkProcessor thread to send information back to peer.

The final section of this thread focuses on ensuring proper payload was sent. The full payload in proper order is 10 bytes (peer listener port), 1650 bytes (main payload), and 16 bytes (checksum). The data received is unpacked, checksum validated for main payload, and then submitted to com.iota.iri.network.Node::preProcessReceivedData method for processing.

if (!crcError) { node.preProcessReceivedData(data, address, "tcp"); }

int processed = 0, dropped = 0;

processor.submit(() -> node.preProcessReceivedData(bytes, address, "udp"));

existingNeighbor = false; List neighbors = node.getNeighbors(); neighbors.stream().filter(n -> n instanceof TCPNeighbor) .map(n -> ((TCPNeighbor) n)) .forEach(n -> { String hisAddress = inet_socket_address.getAddress().getHostAddress(); if (n.getHostAddress().equals(hisAddress)) { existingNeighbor = true; neighbor = n; } } );

final TCPNeighbor fresh_neighbor = new TCPNeighbor(inet_socket_address,false); node.getNeighbors().add(fresh_neighbor); neighbor = fresh_neighbor; Neighbor.incNumPeers();

offset = 0; while (((count = stream.read(data, offset, ReplicatorSinkPool.PORT_BYTES - offset)) != -1) && (offset < ReplicatorSinkPool.PORT_BYTES)) { offset += count; }

Thread exit, if the first 10 bytes of the payload received is not the listener service port or connection is closed. The port value received will be used by the ReplicatorSinkProcessor thread to send information back to peer.

The final section of this thread focuses on ensuring proper payload was sent. The full payload in proper order is 10 bytes (peer listener port), 1650 bytes (main payload), and 16 bytes (checksum). The data received is unpacked, checksum validated for main payload, and then submitted to com.iota.iri.network.Node::preProcessReceivedData method for processing.

if (!crcError) { node.preProcessReceivedData(data, address, "tcp"); }

added 1452 characters in body
Source Link

The value of MAX_PEERS is tested, including connection from unauthorized neighbors. If either of these occur, a log message is reported and connection is closed. Otherwise, neighbor is added to the neighbors array and counter for neighbors is incremented. This is followed by a verification check to ensure an existing neighbor socket connection already exists, if not set one for neighbor object.

final TCPNeighbor fresh_neighbor = new TCPNeighbor(inet_socket_address,false); node.getNeighbors().add(fresh_neighbor); neighbor = fresh_neighbor; Neighbor.incNumPeers();

The next section of the code deals with handling/accepting a peer's request. As you'll see in com.iota.iri.network.ReplicatorSinkProcessor, an initial 10 byte array is sent which contains the listening service port. It is followed by main payload (1650 byte length) and it's 16 byte checksum value (prepended with "0" to fill 16 bytes).

NOTE: ReplicatorSinkPool.PORT_BYTES = 10

offset = 0; while (((count = stream.read(data, offset, ReplicatorSinkPool.PORT_BYTES - offset)) != -1) && (offset

Thread exit, if the first 10 bytes of the payload received is not the listener service port or connection is closed. The port value received will be used by the ReplicatorSinkProcessor thread to send information back to peer.

The final section of this thread focuses on ensuring proper payload was sent. The full payload in proper order is 10 bytes (peer listener port), 1650 bytes (main payload), and 16 bytes (checksum). The data received is unpacked, checksum validated for main payload, and then submitted to com.iota.iri.network.Node::preProcessReceivedData method for processing.

if (!crcError) { node.preProcessReceivedData(data, address, "tcp"); }

The value of MAX_PEERS is tested, including connection from unauthorized neighbors. If either of these occur, a log message is reported and connection is closed. Otherwise, neighbor is added to the neighbors array and counter for neighbors is incremented.

final TCPNeighbor fresh_neighbor = new TCPNeighbor(inet_socket_address,false); node.getNeighbors().add(fresh_neighbor); neighbor = fresh_neighbor; Neighbor.incNumPeers();

The value of MAX_PEERS is tested, including connection from unauthorized neighbors. If either of these occur, a log message is reported and connection is closed. Otherwise, neighbor is added to the neighbors array and counter for neighbors is incremented. This is followed by a verification check to ensure an existing neighbor socket connection already exists, if not set one for neighbor object.

final TCPNeighbor fresh_neighbor = new TCPNeighbor(inet_socket_address,false); node.getNeighbors().add(fresh_neighbor); neighbor = fresh_neighbor; Neighbor.incNumPeers();

The next section of the code deals with handling/accepting a peer's request. As you'll see in com.iota.iri.network.ReplicatorSinkProcessor, an initial 10 byte array is sent which contains the listening service port. It is followed by main payload (1650 byte length) and it's 16 byte checksum value (prepended with "0" to fill 16 bytes).

NOTE: ReplicatorSinkPool.PORT_BYTES = 10

offset = 0; while (((count = stream.read(data, offset, ReplicatorSinkPool.PORT_BYTES - offset)) != -1) && (offset

Thread exit, if the first 10 bytes of the payload received is not the listener service port or connection is closed. The port value received will be used by the ReplicatorSinkProcessor thread to send information back to peer.

The final section of this thread focuses on ensuring proper payload was sent. The full payload in proper order is 10 bytes (peer listener port), 1650 bytes (main payload), and 16 bytes (checksum). The data received is unpacked, checksum validated for main payload, and then submitted to com.iota.iri.network.Node::preProcessReceivedData method for processing.

if (!crcError) { node.preProcessReceivedData(data, address, "tcp"); }
added 1203 characters in body
Source Link

com.iota.iri.network.replicator.ReplicatorSourceProcessor:

The ReplicatorSourceProcessor thread handles the reading and verification of peer packet received. It starts by creating a data byte array with a 2000 byte capacity. It then moves into verifiying the remote peer connection to ensure it's an existing neighbor.

existingNeighbor = false; List neighbors = node.getNeighbors(); neighbors.stream().filter(n -> n instanceof TCPNeighbor) .map(n -> ((TCPNeighbor) n)) .forEach(n -> { String hisAddress = inet_socket_address.getAddress().getHostAddress(); if (n.getHostAddress().equals(hisAddress)) { existingNeighbor = true; neighbor = n; } } );

The value of MAX_PEERS is tested, including connection from unauthorized neighbors. If either of these occur, a log message is reported and connection is closed. Otherwise, neighbor is added to the neighbors array and counter for neighbors is incremented.

final TCPNeighbor fresh_neighbor = new TCPNeighbor(inet_socket_address,false); node.getNeighbors().add(fresh_neighbor); neighbor = fresh_neighbor; Neighbor.incNumPeers();

com.iota.iri.network.replicator.ReplicatorSourceProcessor:

The ReplicatorSourceProcessor thread handles the reading and verification of peer packet received. It starts by creating a data byte array with a 2000 byte capacity. It then moves into verifiying the remote peer connection to ensure it's an existing neighbor.

existingNeighbor = false; List neighbors = node.getNeighbors(); neighbors.stream().filter(n -> n instanceof TCPNeighbor) .map(n -> ((TCPNeighbor) n)) .forEach(n -> { String hisAddress = inet_socket_address.getAddress().getHostAddress(); if (n.getHostAddress().equals(hisAddress)) { existingNeighbor = true; neighbor = n; } } );

The value of MAX_PEERS is tested, including connection from unauthorized neighbors. If either of these occur, a log message is reported and connection is closed. Otherwise, neighbor is added to the neighbors array and counter for neighbors is incremented.

final TCPNeighbor fresh_neighbor = new TCPNeighbor(inet_socket_address,false); node.getNeighbors().add(fresh_neighbor); neighbor = fresh_neighbor; Neighbor.incNumPeers();
added 335 characters in body
Source Link
Loading
added 330 characters in body
Source Link
Loading
added 1362 characters in body
Source Link
Loading
added 2069 characters in body
Source Link
Loading
Source Link
Loading