Wallet: rename lastBlockSeenTime() method from getLastBlockSeenTimeInstant()

This commit is contained in:
Andreas Schildbach 2023-03-18 10:26:13 +01:00
parent e6e4745e1a
commit 516acd51c6
5 changed files with 11 additions and 11 deletions

View File

@ -95,7 +95,7 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
final int height = wallet.getLastBlockSeenHeight();
final Optional<Instant> time = wallet.getLastBlockSeenTimeInstant();
final Optional<Instant> time = wallet.lastBlockSeenTime();
if (!time.isPresent())
return null;

View File

@ -3519,7 +3519,7 @@ public class Wallet extends BaseTaggableObject
builder.append(" ").append(spent.size()).append(" spent\n");
builder.append(" ").append(dead.size()).append(" dead\n");
builder.append("Last seen best block: ").append(getLastBlockSeenHeight()).append(" (")
.append(getLastBlockSeenTimeInstant()
.append(lastBlockSeenTime()
.map(instant -> TimeUtils.dateTimeFormat(instant))
.orElse("time unknown"))
.append("): ").append(getLastBlockSeenHash()).append('\n');
@ -3708,7 +3708,7 @@ public class Wallet extends BaseTaggableObject
* was found, although most miners do use accurate times. If this wallet is old and does not have a recorded
* time then this method returns zero.
*/
public Optional<Instant> getLastBlockSeenTimeInstant() {
public Optional<Instant> lastBlockSeenTime() {
lock.lock();
try {
return Optional.ofNullable(lastBlockSeenTime);
@ -3717,17 +3717,17 @@ public class Wallet extends BaseTaggableObject
}
}
/** @deprecated use {@link #getLastBlockSeenTimeInstant()} */
/** @deprecated use {@link #lastBlockSeenTime()} */
@Deprecated
public long getLastBlockSeenTimeSecs() {
return getLastBlockSeenTimeInstant().map(Instant::getEpochSecond).orElse((long) 0);
return lastBlockSeenTime().map(Instant::getEpochSecond).orElse((long) 0);
}
/** @deprecated use {@link #getLastBlockSeenTimeInstant()} */
/** @deprecated use {@link #lastBlockSeenTime()} */
@Deprecated
@Nullable
public Date getLastBlockSeenTime() {
return getLastBlockSeenTimeInstant().map(Date::from).orElse(null);
return lastBlockSeenTime().map(Date::from).orElse(null);
}
/**

View File

@ -95,7 +95,7 @@ public class WalletFiles {
}
log.info("Background saving wallet; last seen block is height {}, date {}, hash {}",
wallet.getLastBlockSeenHeight(),
wallet.getLastBlockSeenTimeInstant()
wallet.lastBlockSeenTime()
.map(time -> TimeUtils.dateTimeFormat(time))
.orElse("unknown"),
wallet.getLastBlockSeenHash());
@ -129,7 +129,7 @@ public class WalletFiles {
if (executor.isShutdown())
return;
log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(),
wallet.getLastBlockSeenTimeInstant()
wallet.lastBlockSeenTime()
.map(time -> TimeUtils.dateTimeFormat(time))
.orElse("unknown"),
wallet.getLastBlockSeenHash());

View File

@ -201,7 +201,7 @@ public class WalletProtobufSerializer {
walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash));
walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight());
}
wallet.getLastBlockSeenTimeInstant().ifPresent(
wallet.lastBlockSeenTime().ifPresent(
time -> walletBuilder.setLastSeenBlockTimeSecs(time.getEpochSecond()));
// Populate the scrypt parameters.

View File

@ -1538,7 +1538,7 @@ public class WalletTest extends TestWithWallet {
// Receive a block on the best chain - this should set the last block seen hash.
chain.add(b10);
assertEquals(b10.getHash(), wallet.getLastBlockSeenHash());
assertEquals(b10.time(), wallet.getLastBlockSeenTimeInstant().get());
assertEquals(b10.time(), wallet.lastBlockSeenTime().get());
assertEquals(1, wallet.getLastBlockSeenHeight());
// Receive a block on the side chain - this should not change the last block seen hash.
chain.add(b11);