move confirmation logic to blocktransactionhash

This commit is contained in:
Craig Raw 2020-08-09 14:12:40 +02:00
parent d2582c0414
commit fff658a3ab

View file

@ -6,6 +6,9 @@ import java.util.Date;
import java.util.Objects; import java.util.Objects;
public abstract class BlockTransactionHash { public abstract class BlockTransactionHash {
public static final int BLOCKS_TO_CONFIRM = 6;
public static final int BLOCKS_TO_FULLY_CONFIRM = 100;
private final Sha256Hash hash; private final Sha256Hash hash;
private final int height; private final int height;
private final Date date; private final Date date;
@ -32,6 +35,14 @@ public abstract class BlockTransactionHash {
return height; return height;
} }
public int getConfirmations(int currentBlockHeight) {
if(height <= 0) {
return 0;
}
return currentBlockHeight - height + 1;
}
public Date getDate() { public Date getDate() {
return date; return date;
} }