|
|
@ -20,24 +20,43 @@ import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Contains the outputs of processing a block. */ |
|
|
|
public class BlockProcessingResult extends BlockValidationResult { |
|
|
|
public class BlockProcessingResult extends BlockValidationResult { |
|
|
|
|
|
|
|
|
|
|
|
private final Optional<BlockProcessingOutputs> yield; |
|
|
|
private final Optional<BlockProcessingOutputs> yield; |
|
|
|
private final boolean isPartial; |
|
|
|
private final boolean isPartial; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** A result indicating that processing failed. */ |
|
|
|
public static final BlockProcessingResult FAILED = new BlockProcessingResult("processing failed"); |
|
|
|
public static final BlockProcessingResult FAILED = new BlockProcessingResult("processing failed"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A result indicating that processing was successful but incomplete. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param yield the outputs of processing a block |
|
|
|
|
|
|
|
*/ |
|
|
|
public BlockProcessingResult(final Optional<BlockProcessingOutputs> yield) { |
|
|
|
public BlockProcessingResult(final Optional<BlockProcessingOutputs> yield) { |
|
|
|
this.yield = yield; |
|
|
|
this.yield = yield; |
|
|
|
this.isPartial = false; |
|
|
|
this.isPartial = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A result indicating that processing was successful but incomplete. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param yield the outputs of processing a block |
|
|
|
|
|
|
|
* @param isPartial whether the processing was incomplete |
|
|
|
|
|
|
|
*/ |
|
|
|
public BlockProcessingResult( |
|
|
|
public BlockProcessingResult( |
|
|
|
final Optional<BlockProcessingOutputs> yield, final boolean isPartial) { |
|
|
|
final Optional<BlockProcessingOutputs> yield, final boolean isPartial) { |
|
|
|
this.yield = yield; |
|
|
|
this.yield = yield; |
|
|
|
this.isPartial = isPartial; |
|
|
|
this.isPartial = isPartial; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A result indicating that processing was successful but incomplete. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param yield the outputs of processing a block |
|
|
|
|
|
|
|
* @param errorMessage the error message if any |
|
|
|
|
|
|
|
*/ |
|
|
|
public BlockProcessingResult( |
|
|
|
public BlockProcessingResult( |
|
|
|
final Optional<BlockProcessingOutputs> yield, final String errorMessage) { |
|
|
|
final Optional<BlockProcessingOutputs> yield, final String errorMessage) { |
|
|
|
super(errorMessage); |
|
|
|
super(errorMessage); |
|
|
@ -45,6 +64,12 @@ public class BlockProcessingResult extends BlockValidationResult { |
|
|
|
this.isPartial = false; |
|
|
|
this.isPartial = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A result indicating that processing was successful but incomplete. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param yield the outputs of processing a block |
|
|
|
|
|
|
|
* @param cause the cause of the error if any |
|
|
|
|
|
|
|
*/ |
|
|
|
public BlockProcessingResult( |
|
|
|
public BlockProcessingResult( |
|
|
|
final Optional<BlockProcessingOutputs> yield, final Throwable cause) { |
|
|
|
final Optional<BlockProcessingOutputs> yield, final Throwable cause) { |
|
|
|
super(cause.getLocalizedMessage(), cause); |
|
|
|
super(cause.getLocalizedMessage(), cause); |
|
|
@ -52,6 +77,13 @@ public class BlockProcessingResult extends BlockValidationResult { |
|
|
|
this.isPartial = false; |
|
|
|
this.isPartial = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A result indicating that processing was successful but incomplete. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param yield the outputs of processing a block |
|
|
|
|
|
|
|
* @param errorMessage the error message if any |
|
|
|
|
|
|
|
* @param isPartial whether the processing was incomplete |
|
|
|
|
|
|
|
*/ |
|
|
|
public BlockProcessingResult( |
|
|
|
public BlockProcessingResult( |
|
|
|
final Optional<BlockProcessingOutputs> yield, |
|
|
|
final Optional<BlockProcessingOutputs> yield, |
|
|
|
final String errorMessage, |
|
|
|
final String errorMessage, |
|
|
@ -61,20 +93,40 @@ public class BlockProcessingResult extends BlockValidationResult { |
|
|
|
this.isPartial = isPartial; |
|
|
|
this.isPartial = isPartial; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A result indicating that processing failed. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param errorMessage the error message |
|
|
|
|
|
|
|
*/ |
|
|
|
public BlockProcessingResult(final String errorMessage) { |
|
|
|
public BlockProcessingResult(final String errorMessage) { |
|
|
|
super(errorMessage); |
|
|
|
super(errorMessage); |
|
|
|
this.isPartial = false; |
|
|
|
this.isPartial = false; |
|
|
|
this.yield = Optional.empty(); |
|
|
|
this.yield = Optional.empty(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Gets the block processing outputs of the result. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the block processing outputs of the result |
|
|
|
|
|
|
|
*/ |
|
|
|
public Optional<BlockProcessingOutputs> getYield() { |
|
|
|
public Optional<BlockProcessingOutputs> getYield() { |
|
|
|
return yield; |
|
|
|
return yield; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Checks if the processing was incomplete. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return true if the processing was incomplete, false otherwise |
|
|
|
|
|
|
|
*/ |
|
|
|
public boolean isPartial() { |
|
|
|
public boolean isPartial() { |
|
|
|
return isPartial; |
|
|
|
return isPartial; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Gets the transaction receipts of the result. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return the transaction receipts of the result |
|
|
|
|
|
|
|
*/ |
|
|
|
public List<TransactionReceipt> getReceipts() { |
|
|
|
public List<TransactionReceipt> getReceipts() { |
|
|
|
if (yield.isEmpty()) { |
|
|
|
if (yield.isEmpty()) { |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|