use of com.radixdlt.atom.Txn in project radixdlt by radixdlt.
the class WithdrawVoteHandler method handleRequest.
@Override
public UpdateVoteResponse handleRequest(UpdateVoteRequest request) throws CoreApiException {
coreModelMapper.verifyNetwork(request.getNetworkIdentifier());
final Txn signedTx;
try {
signedTx = radixEngine.constructWithFees(this::buildWithdrawVote, false, REAddr.ofPubKeyAccount(validatorKey), NotEnoughNativeTokensForFeesException::new).signAndBuild(hashSigner::sign);
} catch (TxBuilderException e) {
throw CoreApiException.badRequest(coreModelMapper.builderErrorDetails(e));
}
try {
radixEngineStateComputer.addToMempool(signedTx);
return new UpdateVoteResponse().transactionIdentifier(coreModelMapper.transactionIdentifier(signedTx.getId())).duplicate(false);
} catch (MempoolDuplicateException e) {
return new UpdateVoteResponse().transactionIdentifier(coreModelMapper.transactionIdentifier(signedTx.getId())).duplicate(true);
} catch (MempoolFullException e) {
throw coreModelMapper.mempoolFullException(e);
} catch (MempoolRejectedException e) {
throw coreModelMapper.radixEngineException((RadixEngineException) e.getCause());
}
}
use of com.radixdlt.atom.Txn in project radixdlt by radixdlt.
the class LedgerInOrderInvariant method check.
@Override
public Observable<TestInvariantError> check(RunningNetwork network) {
Map<BFTNode, List<Txn>> commandsPerNode = new HashMap<>();
network.getNodes().forEach(n -> commandsPerNode.put(n, new ArrayList<>()));
return network.ledgerUpdates().flatMap(nodeAndCommand -> {
BFTNode node = nodeAndCommand.getFirst();
LedgerUpdate ledgerUpdate = nodeAndCommand.getSecond();
List<Txn> nodeTxns = commandsPerNode.get(node);
nodeTxns.addAll(ledgerUpdate.getNewTxns());
return commandsPerNode.values().stream().filter(list -> nodeTxns != list).filter(list -> list.size() >= nodeTxns.size()).findFirst().flatMap(list -> {
if (Collections.indexOfSubList(list, nodeTxns) != 0) {
TestInvariantError err = new TestInvariantError("Two nodes don't agree on commands: " + list + " " + nodeTxns);
return Optional.of(Observable.just(err));
}
return Optional.empty();
}).orElse(Observable.empty());
});
}
Aggregations