mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-22 20:26:50 +00:00
Fix incorrect orphaning of BUY_NAME transactions.
Orphaning a BUY_NAME transaction would not reinstate the sale price. Sale price could be nullified by (e.g.) orphaning a SELL_NAME transaction. Also added test case to cover above and other test-related support, e.g. test-mode in NTP.
This commit is contained in:
@@ -179,6 +179,7 @@ public class Name {
|
||||
public void unbuy(BuyNameTransactionData buyNameTransactionData) throws DataException {
|
||||
// Mark as for-sale using existing price
|
||||
this.nameData.setIsForSale(true);
|
||||
this.nameData.setSalePrice(buyNameTransactionData.getAmount());
|
||||
|
||||
// Previous name reference is taken from this transaction's cached copy
|
||||
this.nameData.setReference(buyNameTransactionData.getNameReference());
|
||||
|
@@ -127,6 +127,7 @@ public class NTP implements Runnable {
|
||||
if (isStarted)
|
||||
return;
|
||||
|
||||
isStarted = true;
|
||||
instanceExecutor = Executors.newSingleThreadExecutor();
|
||||
instance = new NTP();
|
||||
instanceExecutor.execute(instance);
|
||||
@@ -136,16 +137,21 @@ public class NTP implements Runnable {
|
||||
instanceExecutor.shutdownNow();
|
||||
}
|
||||
|
||||
public static synchronized void testMode() {
|
||||
// Fix offset to match system time
|
||||
NTP.offset = 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns our estimate of internet time.
|
||||
*
|
||||
* @return internet time (ms), or null if unsynchronized.
|
||||
*/
|
||||
public static Long getTime() {
|
||||
if (offset == null)
|
||||
if (NTP.offset == null)
|
||||
return null;
|
||||
|
||||
return System.currentTimeMillis() + offset;
|
||||
return System.currentTimeMillis() + NTP.offset;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
Reference in New Issue
Block a user