Skip to content
Snippets Groups Projects
Commit 556acf46 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

Add a log (warn) to find the origin of issuer #17

parent 905b1d91
No related branches found
No related tags found
No related merge requests found
...@@ -23,10 +23,11 @@ package org.duniter.core.client.model.bma; ...@@ -23,10 +23,11 @@ package org.duniter.core.client.model.bma;
*/ */
import org.duniter.core.util.Preconditions; import org.duniter.core.util.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -38,6 +39,8 @@ import java.util.stream.IntStream; ...@@ -38,6 +39,8 @@ import java.util.stream.IntStream;
*/ */
public final class BlockchainBlocks { public final class BlockchainBlocks {
private static final Logger log = LoggerFactory.getLogger(BlockchainBlocks.class);
public static final Pattern SIG_PUBKEY_PATTERN = Pattern.compile("SIG\\(([^)]+)\\)"); public static final Pattern SIG_PUBKEY_PATTERN = Pattern.compile("SIG\\(([^)]+)\\)");
public static final Pattern TX_INPUT_CONDITION_FUNCTION = Pattern.compile("(SIG|XHX)\\(([^)]+)\\)"); public static final Pattern TX_INPUT_CONDITION_FUNCTION = Pattern.compile("(SIG|XHX)\\(([^)]+)\\)");
...@@ -112,10 +115,20 @@ public final class BlockchainBlocks { ...@@ -112,10 +115,20 @@ public final class BlockchainBlocks {
Preconditions.checkNotNull(tx); Preconditions.checkNotNull(tx);
final Map<Integer, List<String>> inputIssuers = getInputIssuers(tx); final Map<Integer, List<String>> inputIssuers = getInputIssuers(tx);
if (inputIssuers == null || inputIssuers.size() == 0) {
log.warn("Invalid block TX: no issuer found ! ", tx.toString());
}
return IntStream.range(0, tx.getInputs().length) return IntStream.range(0, tx.getInputs().length)
.mapToObj(i -> { .mapToObj(i -> {
TxInput txInput = parseInput(tx.getInputs()[i]); TxInput txInput = parseInput(tx.getInputs()[i]);
if (txInput == null) {
log.warn(String.format("Invalid block TX: unable to parse inputs: %s", i, tx.getInputs()[i]));
txInput = new TxInput();
txInput.amount = 0;
txInput.unitbase = 0;
txInput.type = "T";
}
txInput.issuers = inputIssuers.get(i); txInput.issuers = inputIssuers.get(i);
return txInput; return txInput;
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment