/** * Called when download progress is made. * * @param pct the percentage of chain downloaded, estimated * @param date the date of the last block downloaded */ protected void progress(double pct, int blocksSoFar, Date date) { log.info(String.format(Locale.US, "Chain download %d%% done with %d blocks to go, block date %s", (int) pct, blocksSoFar, Utils.dateTimeFormat(date))); }
/** * Called when download progress is made. * * @param pct the percentage of chain downloaded, estimated * @param date the date of the last block downloaded */ protected void progress(double pct, int blocksSoFar, Date date) { log.info(String.format(Locale.US, "Chain download %d%% done with %d blocks to go, block date %s", (int) pct, blocksSoFar, Utils.dateTimeFormat(date))); }
/** * Called when download progress is made. * * @param pct the percentage of chain downloaded, estimated * @param date the date of the last block downloaded */ protected void progress(double pct, int blocksSoFar, Date date) { log.info(String.format(Locale.US, "Chain download %d%% done with %d blocks to go, block date %s", (int) pct, blocksSoFar, Utils.dateTimeFormat(date))); }
/** * Called when download progress is made. * * @param pct the percentage of chain downloaded, estimated * @param date the date of the last block downloaded */ protected void progress(double pct, int blocksSoFar, Date date) { log.info(String.format(Locale.US, "Chain download %d%% done with %d blocks to go, block date %s", (int) pct, blocksSoFar, Utils.dateTimeFormat(date))); }
private void checkTimestamp() throws VerificationException { final long allowedTime = Utils.currentTimeSeconds() + ALLOWED_TIME_DRIFT; if (time > allowedTime) throw new VerificationException(String.format(Locale.US, "Block too far in future: %s (%d) vs allowed %s (%d)", Utils.dateTimeFormat(time * 1000), time, Utils.dateTimeFormat(allowedTime * 1000), allowedTime)); }
private void checkTimestamp() throws VerificationException { final long allowedTime = Utils.currentTimeSeconds() + ALLOWED_TIME_DRIFT; if (time > allowedTime) throw new VerificationException(String.format(Locale.US, "Block too far in future: %s (%d) vs allowed %s (%d)", Utils.dateTimeFormat(time * 1000), time, Utils.dateTimeFormat(allowedTime * 1000), allowedTime)); }
/** * <p>When a key rotation time is set, any money controlled by keys created before the given timestamp T will be * automatically respent to any key that was created after T. This can be used to recover from a situation where * a set of keys is believed to be compromised. You can stop key rotation by calling this method again with zero * as the argument. Once set up, calling {@link #doMaintenance(org.spongycastle.crypto.params.KeyParameter, boolean)} * will create and possibly send rotation transactions: but it won't be done automatically (because you might have * to ask for the users password).</p> * * <p>The given time cannot be in the future.</p> */ public void setKeyRotationTime(long unixTimeSeconds) { checkArgument(unixTimeSeconds <= Utils.currentTimeSeconds(), "Given time (%s) cannot be in the future.", Utils.dateTimeFormat(unixTimeSeconds * 1000)); vKeyRotationTimestamp = unixTimeSeconds; saveNow(); }
/** * <p>When a key rotation time is set, any money controlled by keys created before the given timestamp T will be * automatically respent to any key that was created after T. This can be used to recover from a situation where * a set of keys is believed to be compromised. You can stop key rotation by calling this method again with zero * as the argument. Once set up, calling {@link #doMaintenance(org.spongycastle.crypto.params.KeyParameter, boolean)} * will create and possibly send rotation transactions: but it won't be done automatically (because you might have * to ask for the users password).</p> * * <p>The given time cannot be in the future.</p> */ public void setKeyRotationTime(long unixTimeSeconds) { checkArgument(unixTimeSeconds <= Utils.currentTimeSeconds(), "Given time (%s) cannot be in the future.", Utils.dateTimeFormat(unixTimeSeconds * 1000)); vKeyRotationTimestamp = unixTimeSeconds; saveNow(); }
/** * <p>When a key rotation time is set, any money controlled by keys created before the given timestamp T will be * automatically respent to any key that was created after T. This can be used to recover from a situation where * a set of keys is believed to be compromised. You can stop key rotation by calling this method again with zero * as the argument. Once set up, calling {@link #doMaintenance(org.spongycastle.crypto.params.KeyParameter, boolean)} * will create and possibly send rotation transactions: but it won't be done automatically (because you might have * to ask for the users password).</p> * * <p>The given time cannot be in the future.</p> */ public void setKeyRotationTime(long unixTimeSeconds) { checkArgument(unixTimeSeconds <= Utils.currentTimeSeconds(), "Given time (%s) cannot be in the future.", Utils.dateTimeFormat(unixTimeSeconds * 1000)); vKeyRotationTimestamp = unixTimeSeconds; saveNow(); }
@Override public Void call() throws Exception { // Runs in an auto save thread. if (!savePending.getAndSet(false)) { // Some other scheduled request already beat us to it. return null; } Date lastBlockSeenTime = wallet.getLastBlockSeenTime(); log.info("Background saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(), lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown", wallet.getLastBlockSeenHash()); saveNowInternal(); return null; } };
@Override public Void call() throws Exception { // Runs in an auto save thread. if (!savePending.getAndSet(false)) { // Some other scheduled request already beat us to it. return null; } Date lastBlockSeenTime = wallet.getLastBlockSeenTime(); log.info("Background saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(), lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown", wallet.getLastBlockSeenHash()); saveNowInternal(); return null; } };
@Override public Void call() throws Exception { // Runs in an auto save thread. if (!savePending.getAndSet(false)) { // Some other scheduled request already beat us to it. return null; } Date lastBlockSeenTime = wallet.getLastBlockSeenTime(); log.info("Background saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(), lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown", wallet.getLastBlockSeenHash()); saveNowInternal(); return null; } };
@Override public Void call() throws Exception { // Runs in an auto save thread. if (!savePending.getAndSet(false)) { // Some other scheduled request already beat us to it. return null; } Date lastBlockSeenTime = wallet.getLastBlockSeenTime(); log.info("Background saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(), lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown", wallet.getLastBlockSeenHash()); saveNowInternal(); return null; } };
private static void setCreationTime() { DeterministicSeed seed = wallet.getActiveKeyChain().getSeed(); if (seed == null) { System.err.println("Active chain does not have a seed."); return; } long creationTime = getCreationTimeSeconds(); if (creationTime > 0) System.out.println("Setting creation time to: " + Utils.dateTimeFormat(creationTime * 1000)); else System.out.println("Clearing creation time."); seed.setCreationTimeSeconds(creationTime); }
/** Actually write the wallet file to disk, using an atomic rename when possible. Runs on the current thread. */ public void saveNow() throws IOException { // Can be called by any thread. However the wallet is locked whilst saving, so we can have two saves in flight // but they will serialize (using different temp files). Date lastBlockSeenTime = wallet.getLastBlockSeenTime(); log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(), lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown", wallet.getLastBlockSeenHash()); saveNowInternal(); }
/** Actually write the wallet file to disk, using an atomic rename when possible. Runs on the current thread. */ public void saveNow() throws IOException { // Can be called by any thread. However the wallet is locked whilst saving, so we can have two saves in flight // but they will serialize (using different temp files). Date lastBlockSeenTime = wallet.getLastBlockSeenTime(); log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(), lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown", wallet.getLastBlockSeenHash()); saveNowInternal(); }
/** Actually write the wallet file to disk, using an atomic rename when possible. Runs on the current thread. */ public void saveNow() throws IOException { // Can be called by any thread. However the wallet is locked whilst saving, so we can have two saves in flight // but they will serialize (using different temp files). Date lastBlockSeenTime = wallet.getLastBlockSeenTime(); log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(), lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown", wallet.getLastBlockSeenHash()); saveNowInternal(); }
/** Actually write the wallet file to disk, using an atomic rename when possible. Runs on the current thread. */ public void saveNow() throws IOException { // Can be called by any thread. However the wallet is locked whilst saving, so we can have two saves in flight // but they will serialize (using different temp files). if (executor.isShutdown()) return; Date lastBlockSeenTime = wallet.getLastBlockSeenTime(); log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(), lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown", wallet.getLastBlockSeenHash()); saveNowInternal(); }
@Test public void dateTimeFormat() { assertEquals("2014-11-16T10:54:33Z", Utils.dateTimeFormat(1416135273781L)); assertEquals("2014-11-16T10:54:33Z", Utils.dateTimeFormat(new Date(1416135273781L))); } }
@Override public void notifyNewBestBlock(StoredBlock block) throws VerificationException { int height = block.getHeight(); if (height % CoinDefinition.getIntervalCheckpoints() == 0 && block.getHeader().getTimeSeconds() <= timeAgo) { System.out.println(String.format("Checkpointing block %s at height %d, time %s", block.getHeader().getHash(), block.getHeight(), Utils.dateTimeFormat(block.getHeader().getTime()))); checkpoints.put(height, block); } } });