Skip to content

Commit

Permalink
TransactionConfidence: rename getLastBroadcastTime() method from `l…
Browse files Browse the repository at this point in the history
…astBroadcastTime()`

This effectively reverts commit c2cabea.
  • Loading branch information
schildbach committed May 5, 2024
1 parent 1dbb12d commit be8826c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ public boolean wasBroadcastBy(PeerAddress address) {
* Return the time the transaction was last announced to us, or empty if unknown.
* @return time the transaction was last announced to us, or empty if unknown
*/
public Optional<Instant> lastBroadcastTime() {
public Optional<Instant> getLastBroadcastTime() {
return Optional.ofNullable(lastBroadcastTime);
}

/** @deprecated use {@link #lastBroadcastTime()} */
/** @deprecated use {@link #getLastBroadcastTime()} */
@Deprecated
@Nullable
public Date getLastBroadcastedAt() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private static void writeConfidence(Protos.Transaction.Builder txBuilder,
.build();
confidenceBuilder.addBroadcastBy(proto);
}
confidence.lastBroadcastTime().ifPresent(
confidence.getLastBroadcastTime().ifPresent(
lastBroadcastTime -> confidenceBuilder.setLastBroadcastedAt(lastBroadcastTime.toEpochMilli())
);
txBuilder.setConfidence(confidenceBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void oneTx() throws Exception {
Transaction t1copy = wallet1.getTransaction(t1.getTxId());
assertArrayEquals(t1.serialize(), t1copy.serialize());
assertEquals(2, t1copy.getConfidence().numBroadcastPeers());
assertNotNull(t1copy.getConfidence().lastBroadcastTime());
assertNotNull(t1copy.getConfidence().getLastBroadcastTime());
assertEquals(TransactionConfidence.Source.NETWORK, t1copy.getConfidence().getSource());

Protos.Wallet walletProto = new WalletProtobufSerializer().walletToProto(myWallet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public void transactionConfidence() throws Exception {
InventoryMessage inv = InventoryMessage.ofTransactions(tx);

assertEquals(0, tx.getConfidence().numBroadcastPeers());
assertFalse(tx.getConfidence().lastBroadcastTime().isPresent());
assertFalse(tx.getConfidence().getLastBroadcastTime().isPresent());

// Peer 2 advertises the tx but does not receive it yet.
inbound(p2, inv);
Expand All @@ -408,7 +408,7 @@ public void transactionConfidence() throws Exception {
assertEquals(2, tx.getConfidence().numBroadcastPeers());
assertTrue(tx.getConfidence().wasBroadcastBy(peerOf(p1).getAddress()));
assertTrue(tx.getConfidence().wasBroadcastBy(peerOf(p2).getAddress()));
assertTrue(tx.getConfidence().lastBroadcastTime().isPresent());
assertTrue(tx.getConfidence().getLastBroadcastTime().isPresent());

tx.getConfidence().addEventListener((confidence, reason) -> confEvent[0] = confidence);
// A straggler reports in.
Expand Down

0 comments on commit be8826c

Please sign in to comment.