Skip to content

Commit

Permalink
Fixes for sequence number handling with local Convex instance
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Sep 21, 2023
1 parent 5765fd1 commit 00be926
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions convex-peer/src/main/java/convex/api/Convex.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,16 +383,22 @@ private synchronized ATransaction applyNextSequence(ATransaction t) {
* @throws IOException If an IO Exception occurs (most likely the connection is broken)
*/
public synchronized CompletableFuture<Result> transact(ATransaction transaction) throws IOException {
if (transaction.getOrigin() == null) {
transaction = transaction.withOrigin(address);
Address origin=transaction.getOrigin();
if (origin == null) {
origin=address;
transaction = transaction.withOrigin(origin);

}
long seq=transaction.getSequence();
if (autoSequence && (seq <= 0)) {
Address origin=transaction.getOrigin();
// apply sequence if using expected address
if (Utils.equals(origin, address)) {
transaction = applyNextSequence(transaction);
if (autoSequence) {
if (seq <= 0) {
// apply sequence if using expected address
if (Utils.equals(origin, address)) {
transaction = applyNextSequence(transaction);
}
}

// If local, do extra
Server s=getLocalServer();
if (s!=null) {
State state=s.getPeer().getConsensusState();
Expand Down

0 comments on commit 00be926

Please sign in to comment.