From be8826c6a6fbe9c442b8c079784512ea706b4abe Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Sun, 5 May 2024 17:10:22 +0200 Subject: [PATCH] TransactionConfidence: rename `getLastBroadcastTime()` method from `lastBroadcastTime()` This effectively reverts commit c2cabead9ac129cd9198438f9ab57a8071ab5669. --- .../main/java/org/bitcoinj/core/TransactionConfidence.java | 4 ++-- .../java/org/bitcoinj/wallet/WalletProtobufSerializer.java | 2 +- .../java/org/bitcoinj/store/WalletProtobufSerializerTest.java | 2 +- .../src/test/java/org/bitcoinj/core/PeerGroupTest.java | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/TransactionConfidence.java b/core/src/main/java/org/bitcoinj/core/TransactionConfidence.java index da20ff2ed2c..e393731cf55 100644 --- a/core/src/main/java/org/bitcoinj/core/TransactionConfidence.java +++ b/core/src/main/java/org/bitcoinj/core/TransactionConfidence.java @@ -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 lastBroadcastTime() { + public Optional getLastBroadcastTime() { return Optional.ofNullable(lastBroadcastTime); } - /** @deprecated use {@link #lastBroadcastTime()} */ + /** @deprecated use {@link #getLastBroadcastTime()} */ @Deprecated @Nullable public Date getLastBroadcastedAt() { diff --git a/core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java b/core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java index 22f522cd9b6..aa93be6759f 100644 --- a/core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java +++ b/core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java @@ -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); diff --git a/core/src/test/java/org/bitcoinj/store/WalletProtobufSerializerTest.java b/core/src/test/java/org/bitcoinj/store/WalletProtobufSerializerTest.java index 25cfb54b386..ca0fae09cd5 100644 --- a/core/src/test/java/org/bitcoinj/store/WalletProtobufSerializerTest.java +++ b/core/src/test/java/org/bitcoinj/store/WalletProtobufSerializerTest.java @@ -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); diff --git a/integration-test/src/test/java/org/bitcoinj/core/PeerGroupTest.java b/integration-test/src/test/java/org/bitcoinj/core/PeerGroupTest.java index a6bca074e08..856fb75ccca 100644 --- a/integration-test/src/test/java/org/bitcoinj/core/PeerGroupTest.java +++ b/integration-test/src/test/java/org/bitcoinj/core/PeerGroupTest.java @@ -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); @@ -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.