Commit 48473806 authored by zeroleak's avatar zeroleak
Browse files

add IIndexHandler.set(int value, boolean allowDecrement)

parent d5d0d808
......@@ -38,7 +38,7 @@ public abstract class AbstractIndexHandler implements IIndexHandler {
@Override
public synchronized void confirmUnconfirmed(final int confirmed) {
if (confirmed >= get()) {
set(confirmed + 1);
set(confirmed + 1, false);
}
Iterator<Integer> it = unconfirmedIndexs.iterator();
......@@ -63,4 +63,14 @@ public abstract class AbstractIndexHandler implements IIndexHandler {
public synchronized void cancelUnconfirmed(int unconfirmed) {
unconfirmedIndexs.remove(unconfirmed);
}
@Override
public void set(int value, boolean allowDecrement) {
if (!allowDecrement && value <= get()) {
return; // deny decrement
}
set(value);
}
protected abstract void set(int value);
}
......@@ -7,7 +7,7 @@ public interface IIndexHandler {
int get();
void set(int value);
void set(int value, boolean allowDecrement);
int getAndIncrementUnconfirmed();
......
......@@ -25,7 +25,7 @@ public class MemoryIndexHandler extends AbstractIndexHandler {
}
@Override
public synchronized void set(int value) {
protected synchronized void set(int value) {
index = value;
}
}
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.samourai.code.wallet</groupId>
<artifactId>extlibj</artifactId>
<version>0.0.25</version>
<version>0.0.26-SNAPSHOT</version>
<name>extlibj</name>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
......
......@@ -46,8 +46,8 @@ public class SimpleUtxoProvider extends SimpleUtxoKeyProvider implements UtxoPro
}
public void clear() {
indexHandler.set(0);
indexChangeHandler.set(0);
indexHandler.set(0, true);
indexChangeHandler.set(0, true);
// clear utxos
nbUtxos=0;
......@@ -58,8 +58,8 @@ public class SimpleUtxoProvider extends SimpleUtxoKeyProvider implements UtxoPro
// reset indexs
for (WhirlpoolAccount account : WhirlpoolAccount.values()) {
for (AddressType addressType : account.getAddressTypes()) {
walletsByAccount.get(account).get(addressType).getIndexHandler().set(0);
walletsByAccount.get(account).get(addressType).getIndexChangeHandler().set(0);
walletsByAccount.get(account).get(addressType).getIndexHandler().set(0, true);
walletsByAccount.get(account).get(addressType).getIndexChangeHandler().set(0, true);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment