mirror of
https://github.com/Qortal/qortal.git
synced 2025-06-05 15:57:00 +00:00
Various fixes as a result of moving to archive version 2.
This commit is contained in:
parent
0af6fbe1eb
commit
1153519d78
@ -70,6 +70,9 @@ public class BlockArchiveReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Triple<byte[], Integer, Integer> serializedBlock = this.fetchSerializedBlockBytesForHeight(height);
|
Triple<byte[], Integer, Integer> serializedBlock = this.fetchSerializedBlockBytesForHeight(height);
|
||||||
|
if (serializedBlock == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
byte[] serializedBytes = serializedBlock.getA();
|
byte[] serializedBytes = serializedBlock.getA();
|
||||||
Integer serializationVersion = serializedBlock.getB();
|
Integer serializationVersion = serializedBlock.getB();
|
||||||
if (serializedBytes == null || serializationVersion == null) {
|
if (serializedBytes == null || serializationVersion == null) {
|
||||||
@ -188,6 +191,9 @@ public class BlockArchiveReader {
|
|||||||
Integer height = this.fetchHeightForSignature(signature, repository);
|
Integer height = this.fetchHeightForSignature(signature, repository);
|
||||||
if (height != null) {
|
if (height != null) {
|
||||||
Triple<byte[], Integer, Integer> serializedBlock = this.fetchSerializedBlockBytesForHeight(height);
|
Triple<byte[], Integer, Integer> serializedBlock = this.fetchSerializedBlockBytesForHeight(height);
|
||||||
|
if (serializedBlock == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
byte[] blockBytes = serializedBlock.getA();
|
byte[] blockBytes = serializedBlock.getA();
|
||||||
Integer version = serializedBlock.getB();
|
Integer version = serializedBlock.getB();
|
||||||
if (blockBytes == null || version == null) {
|
if (blockBytes == null || version == null) {
|
||||||
|
@ -134,6 +134,7 @@ public class BlockArchiveWriter {
|
|||||||
return BlockArchiveWriteResult.STOPPING;
|
return BlockArchiveWriteResult.STOPPING;
|
||||||
}
|
}
|
||||||
if (Synchronizer.getInstance().isSynchronizing()) {
|
if (Synchronizer.getInstance().isSynchronizing()) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,9 +181,12 @@ public class BlockArchiveWriter {
|
|||||||
if (atStatesHash != null) {
|
if (atStatesHash != null) {
|
||||||
block = new Block(repository, blockData, transactions, atStatesHash);
|
block = new Block(repository, blockData, transactions, atStatesHash);
|
||||||
}
|
}
|
||||||
else {
|
else if (atStates != null) {
|
||||||
block = new Block(repository, blockData, transactions, atStates);
|
block = new Block(repository, blockData, transactions, atStates);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
block = new Block(repository, blockData);
|
||||||
|
}
|
||||||
|
|
||||||
// Write the block data to some byte buffers
|
// Write the block data to some byte buffers
|
||||||
int blockIndex = bytes.size();
|
int blockIndex = bytes.size();
|
||||||
|
@ -21,6 +21,16 @@ public class BlockArchiveUtils {
|
|||||||
* into the HSQLDB, in order to make it SQL-compatible
|
* into the HSQLDB, in order to make it SQL-compatible
|
||||||
* again.
|
* again.
|
||||||
* <p>
|
* <p>
|
||||||
|
* This is only fully compatible with archives that use
|
||||||
|
* serialization version 1. For version 2 (or above),
|
||||||
|
* we are unable to import individual AT states as we
|
||||||
|
* only have a single combined hash, so the use cases
|
||||||
|
* for this are greatly limited.
|
||||||
|
* <p>
|
||||||
|
* A version 1 archive should ultimately be rebuildable
|
||||||
|
* via a resync or reindex from genesis, allowing
|
||||||
|
* access to this feature once again.
|
||||||
|
* <p>
|
||||||
* Note: calls discardChanges() and saveChanges(), so
|
* Note: calls discardChanges() and saveChanges(), so
|
||||||
* make sure that you commit any existing repository
|
* make sure that you commit any existing repository
|
||||||
* changes before calling this method.
|
* changes before calling this method.
|
||||||
@ -61,9 +71,18 @@ public class BlockArchiveUtils {
|
|||||||
repository.getBlockRepository().save(blockInfo.getBlockData());
|
repository.getBlockRepository().save(blockInfo.getBlockData());
|
||||||
|
|
||||||
// Save AT state data hashes
|
// Save AT state data hashes
|
||||||
for (ATStateData atStateData : blockInfo.getAtStates()) {
|
if (blockInfo.getAtStates() != null) {
|
||||||
atStateData.setHeight(blockInfo.getBlockData().getHeight());
|
for (ATStateData atStateData : blockInfo.getAtStates()) {
|
||||||
repository.getATRepository().save(atStateData);
|
atStateData.setHeight(blockInfo.getBlockData().getHeight());
|
||||||
|
repository.getATRepository().save(atStateData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// We don't have AT state hashes, so we are only importing a partial state.
|
||||||
|
// This can still be useful to allow orphaning to very old blocks, when we
|
||||||
|
// need to access other chainstate info (such as balances) at an earlier block.
|
||||||
|
// In order to do this, the orphan process must be temporarily adjusted to avoid
|
||||||
|
// orphaning AT states, as it will otherwise fail due to having no previous state.
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user