use of com.icodici.universa.node2.NodeInfo in project universa by UniversaBlockchain.
the class NetworkV2 method unpack.
private List<Notification> unpack(byte[] packedNotifications) throws IOException {
List<Notification> nn = new ArrayList<>();
try {
// packet type code
Boss.Reader r = new Boss.Reader(packedNotifications);
if (r.readInt() != 1)
throw new IOException("invalid packed notification type code");
// from node number
int number = r.readInt();
NodeInfo from = getInfo(number);
if (from == null)
throw new IOException(myInfo.getNumber() + ": unknown node number: " + number);
// number of notifications in the packet
int count = r.readInt();
if (count < 0 || count > 1000)
throw new IOException("unvalid packed notifications count: " + count);
for (int i = 0; i < count; i++) {
nn.add(Notification.read(from, r));
}
return nn;
} catch (Exception e) {
// e.printStackTrace();
report(getLabel(), "failed to unpack notification: " + e, DatagramAdapter.VerboseLevel.BASE);
throw new IOException("failed to unpack notifications", e);
}
}
Aggregations