mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Fix snapshot handling
- Fix wrong start height - Improve logging
This commit is contained in:
parent
97479e295c
commit
8eabd665c7
@ -67,4 +67,10 @@ public abstract class NetworkEnvelope implements Envelope {
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NetworkEnvelope{" +
|
||||
"\n messageVersion=" + messageVersion +
|
||||
"\n}";
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,11 @@ public abstract class BsqNode implements DaoSetupService {
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected int getStartBlockHeight() {
|
||||
final int startBlockHeight = Math.max(genesisBlockHeight, bsqStateService.getChainHeight());
|
||||
int chainHeight = bsqStateService.getChainHeight();
|
||||
int startBlockHeight = chainHeight;
|
||||
if (chainHeight > genesisBlockHeight)
|
||||
startBlockHeight = chainHeight + 1;
|
||||
|
||||
log.info("Start parse blocks:\n" +
|
||||
" Start block height={}\n" +
|
||||
" Genesis txId={}\n" +
|
||||
@ -164,7 +168,7 @@ public abstract class BsqNode implements DaoSetupService {
|
||||
startBlockHeight,
|
||||
genesisTxId,
|
||||
genesisBlockHeight,
|
||||
bsqStateService.getChainHeight());
|
||||
chainHeight);
|
||||
|
||||
return startBlockHeight;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
/**
|
||||
* Main class for a full node which have Bitcoin Core with rpc running and does the blockchain lookup itself.
|
||||
* It also provides the BSQ transactions to lite nodes on request and broadcasts new BSQ blocks.
|
||||
*
|
||||
* <p>
|
||||
* TODO request p2p network data again after parsing is complete to be sure that in case we missed data during parsing
|
||||
* we get it added.
|
||||
*/
|
||||
@ -188,8 +188,8 @@ public class FullNode extends BsqNode {
|
||||
parseBlocksIfNewBlockAvailable(chainHeadHeight);
|
||||
}, throwable -> {
|
||||
if (throwable instanceof BlockNotConnectingException) {
|
||||
int blockHeightOfLastBlock = bsqStateService.getBlockHeightOfLastBlock();
|
||||
requestChainHeadHeightAndParseBlocks(blockHeightOfLastBlock);
|
||||
int startHeight = bsqStateService.getBlockHeightOfLastBlock() + 1;
|
||||
requestChainHeadHeightAndParseBlocks(startHeight);
|
||||
} else {
|
||||
handleError(throwable);
|
||||
}
|
||||
@ -232,6 +232,8 @@ public class FullNode extends BsqNode {
|
||||
} catch (BlockNotConnectingException e) {
|
||||
errorHandler.accept(e);
|
||||
}
|
||||
} else {
|
||||
log.info("Block was already added height=", rawBlock.getHeight());
|
||||
}
|
||||
},
|
||||
errorHandler);
|
||||
|
@ -126,14 +126,14 @@ public class RequestBlocksHandler implements MessageListener {
|
||||
TIMEOUT);
|
||||
}
|
||||
|
||||
log.info("We send a {} to peer {}. ", getBlocksRequest.getClass().getSimpleName(), nodeAddress);
|
||||
log.info("We send to peer {} a {}.", nodeAddress, getBlocksRequest);
|
||||
networkNode.addMessageListener(this);
|
||||
SettableFuture<Connection> future = networkNode.sendMessage(nodeAddress, getBlocksRequest);
|
||||
Futures.addCallback(future, new FutureCallback<Connection>() {
|
||||
@Override
|
||||
public void onSuccess(Connection connection) {
|
||||
if (!stopped) {
|
||||
log.info("Send " + getBlocksRequest + " to " + nodeAddress + " succeeded.");
|
||||
log.info("Sending of GetBlocksRequest message to peer {} succeeded.", nodeAddress.getHostName());
|
||||
} else {
|
||||
log.trace("We have stopped already. We ignore that networkNode.sendMessage.onSuccess call." +
|
||||
"Might be caused by an previous timeout.");
|
||||
@ -178,7 +178,7 @@ public class RequestBlocksHandler implements MessageListener {
|
||||
"RequestDataHandler.onMessage: connection.getPeersNodeAddressOptional() must be present " +
|
||||
"at that moment");
|
||||
cleanup();
|
||||
log.info("We received a GetBlocksResponse from peer ={}", nodeAddress.getFullAddress());
|
||||
log.info("We received from peer {} a {}", nodeAddress.getFullAddress(), getBlocksResponse);
|
||||
listener.onComplete(getBlocksResponse);
|
||||
} else {
|
||||
log.warn("Nonce not matching. That can happen rarely if we get a response after a canceled " +
|
||||
|
@ -32,11 +32,9 @@ import java.util.List;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Getter
|
||||
@ToString
|
||||
public final class GetBlocksRequest extends NetworkEnvelope implements DirectMessage, CapabilityRequiringPayload {
|
||||
private final int fromBlockHeight;
|
||||
private final int nonce;
|
||||
|
@ -37,11 +37,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Manages snapshots of BsqState.
|
||||
* // FIXME not working correctly anymore
|
||||
*/
|
||||
@Slf4j
|
||||
public class SnapshotManager implements BsqStateListener {
|
||||
private static final int SNAPSHOT_GRID = 110000000;
|
||||
private static final int SNAPSHOT_GRID = 100;
|
||||
|
||||
private final BsqState bsqState;
|
||||
private final BsqStateService bsqStateService;
|
||||
@ -90,7 +89,7 @@ public class SnapshotManager implements BsqStateListener {
|
||||
// Now we clone and keep it in memory for the next trigger
|
||||
snapshotCandidate = bsqState.getClone();
|
||||
// don't access cloned anymore with methods as locks are transient!
|
||||
log.debug("Cloned new snapshotCandidate at height " + chainHeadHeight);
|
||||
log.info("Cloned new snapshotCandidate at height " + chainHeadHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<configuration>
|
||||
<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%highlight(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{15}: %msg %xEx%n)</pattern>
|
||||
<pattern>%highlight(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{30}: %msg %xEx%n)</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
@ -11,4 +11,7 @@
|
||||
</root>
|
||||
|
||||
<logger name="com.neemre.btcdcli4j" level="WARN"/>
|
||||
<!-- <logger name="bisq.core.provider" level="WARN"/>
|
||||
<logger name="bisq.network" level="WARN"/>-->
|
||||
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user