Skip to content
Permalink
Browse files

Version 548. Changed full-mesh queries to cycle only.

  • Loading branch information...
n-y-z-o committed Oct 1, 2019
1 parent e70acf1 commit 6c810157bdf9adc08417223fce703c6e25bc7f3d
@@ -38,11 +38,6 @@
} catch (Exception ignored) { }
}

// We do not broadcast any messages to the full mesh from the broadcast method. We do, however, use the full mesh
// as a potential pool for random requests for the following types. This reduces strain on in-cycle verifiers.
private static final Set<MessageType> fullMeshMessageTypes = new HashSet<>(Arrays.asList(MessageType.BlockRequest11,
MessageType.BlockWithVotesRequest37));

static {
loadWhitelist();
}
@@ -154,16 +149,13 @@ public static void fetchFromRandomNode(Message message, MessageCallback messageC

private static Node randomNode(MessageType messageType) {

boolean isFullMeshMessage = fullMeshMessageTypes.contains(messageType);

Node node = null;
List<Node> mesh = NodeManager.getMesh();
List<Node> mesh = NodeManager.getCycle();
Random random = new Random();
while (node == null && !mesh.isEmpty()) {
Node meshNode = mesh.remove(random.nextInt(mesh.size()));
ByteBuffer nodeIdentifierBuffer = ByteBuffer.wrap(meshNode.getIdentifier());
if (!ByteUtil.arraysAreEqual(meshNode.getIdentifier(), Verifier.getIdentifier()) && (isFullMeshMessage ||
BlockManager.verifierInCurrentCycle(nodeIdentifierBuffer) || !BlockManager.isCycleComplete())) {
if (!ByteUtil.arraysAreEqual(meshNode.getIdentifier(), Verifier.getIdentifier())) {
node = meshNode;
}
}
@@ -2,7 +2,7 @@

public class Version {

private static final int version = 547;
private static final int version = 548;

public static int getVersion() {

@@ -101,9 +101,9 @@ private static void start() {
startThreadForVerifier(verifier, querySlot++);
}

// Start a single thread as a fallback for fetching blocks from the full mesh if all managed verifiers become
// Start a single thread as a fallback for fetching blocks from the full cycle if all managed verifiers become
// unresponsive.
startFullMeshThread();
startFullCycleThread();

// Start a single thread for transmitting blocks for new verifiers.
startNewVerifierThread();
@@ -179,7 +179,7 @@ public void run() {
}).start();
}

private static void startFullMeshThread() {
private static void startFullCycleThread() {

new Thread(new Runnable() {
@Override

0 comments on commit 6c81015

Please sign in to comment.
You can’t perform that action at this time.