Issue # 5: fixed test and initialisation

This commit is contained in:
2015-06-17 06:23:00 +02:00
parent 9b0de83706
commit 1dc4582012
4 changed files with 23 additions and 8 deletions

View File

@ -159,7 +159,7 @@ public class Connection implements Runnable {
}
break;
default:
throw new RuntimeException("Command 'version' or 'verack' expected, but was '"
throw new NodeException("Command 'version' or 'verack' expected, but was '"
+ msg.getPayload().getCommand() + "'");
}
}
@ -173,6 +173,9 @@ public class Connection implements Runnable {
} catch (IOException | NodeException e) {
LOG.debug("disconnection from node " + node + ": " + e.getMessage(), e);
disconnect();
} catch (RuntimeException e) {
disconnect();
throw e;
}
}
@ -215,6 +218,8 @@ public class Connection implements Runnable {
listener.receive(objectMessage);
ctx.getInventory().storeObject(objectMessage);
// offer object to some random nodes so it gets distributed throughout the network:
// FIXME: don't do this while we catch up after initialising our first connection
// (that might be a bit tricky to do)
ctx.getNetworkHandler().offer(objectMessage.getInventoryVector());
} catch (InsufficientProofOfWorkException e) {
LOG.warn(e.getMessage());