public String toString() { return "[ItemNotification from " + getFrom() + " for item: " + getItemId() + ", item result: " + itemResult + ", is answer requested: " + answerIsRequested() + "]"; }
static public void init() { registerClass(CODE_ITEM_NOTIFICATION, ItemNotification.class); } }
Object x = checkItemInternal(notification.getItemId(), null, null, true, true); NodeInfo from = notification.getFrom(); ItemResult r = (ItemResult) x; if (notification.answerIsRequested()) { network.deliver( from, new ParcelNotification(myInfo, notification.getItemId(), null, r, ItemResult result = notification.getItemResult(); ip.lock(() -> { ip.vote(from, result.state); else log.e("pending vote on item " + notification.getItemId() + " from " + from); if (notification.answerIsRequested() && ip.record.getState() != ItemState.PENDING) { network.deliver( from, new ParcelNotification(myInfo, notification.getItemId(), null, ip.getResult(),
@Test public void packUnpack() throws Exception { NodeInfo ni = new NodeInfo(TestKeys.publicKey(0),1, "test1", "localhost", 17101, 17102, 17104); HashId id1 = HashId.createRandom(); ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.SECONDS); ZonedDateTime expiresAt = now.plusDays(30); ItemResult ir1 = new ItemResult(ItemState.PENDING, false, now, expiresAt); ItemResult ir2 = new ItemResult(ItemState.REVOKED, true, now, expiresAt); ItemNotification n1 = new ItemNotification(ni, id1, ir1, true); ItemNotification n2 = new ItemNotification(ni, id1, ir1, false); ItemNotification n3 = new ItemNotification(ni, id1, ir1, true); byte[] packed = Notification.pack(asList(n1, n2, n3)); List<Notification> l = Notification.unpack(ni, packed); assertEquals(3, l.size()); ItemNotification n = (ItemNotification) l.get(0); assertEquals(n, n1); n = (ItemNotification) l.get(1); assertEquals(n, n2); n = (ItemNotification) l.get(2); assertEquals(n, n3); }
@Override protected void writeTo(Boss.Writer bw) throws IOException { super.writeTo(bw); bw.writeObject(type.ordinal()); if(parcelId != null) bw.writeObject(parcelId.getDigest()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ItemNotification that = (ItemNotification) o; NodeInfo from = getFrom(); if (requestResult != that.requestResult) return false; if (!from.equals(that.getFrom())) return false; if (!itemId.equals(that.itemId)) return false; return itemResult.equals(that.itemResult); }
@Override protected void readFrom(Boss.Reader br) throws IOException { super.readFrom(br); type = ParcelNotificationType.values()[br.readInt()]; try { byte[] parcelBytes = br.readBinary(); if (parcelBytes != null) parcelId = HashId.withDigest(parcelBytes); } catch (IOException e) { parcelId = null; } }
finalTo.getNumber(), " IN ", ((ItemNotification)notification).getItemId().toString()), DatagramAdapter.VerboseLevel.DETAILED); } else {
System.out.println("fired"); }); n0.deliver(i1, new ItemNotification(i0, HashId.createRandom(), new ItemResult(ItemState.PENDING,
@Override protected void writeTo(Boss.Writer bw) throws IOException { super.writeTo(bw); if (!answerIsRequested()) { bw.write(itemState.ordinal()); bw.write(hasEnvironment); } }
@Override public int hashCode() { NodeInfo from = getFrom(); int result = from.hashCode(); result = 31 * result + itemId.hashCode(); result = 31 * result + itemResult.hashCode(); result = 31 * result + (requestResult ? 1 : 0); return result; }
@Override protected void readFrom(Boss.Reader br) throws IOException { super.readFrom(br); if (!answerIsRequested()) { itemState = ItemState.values()[br.readInt()]; hasEnvironment = br.readInt(); } }
System.out.println("fired"); }); n0.deliver(i1, new ItemNotification(i0, HashId.createRandom(), new ItemResult(ItemState.PENDING,