/// <summary> /// Commits a transaction to the DAppChain. /// </summary> /// <param name="tx">Transaction to commit.</param> /// <returns>Commit metadata.</returns> /// <exception cref="InvalidTxNonceException">Thrown if transaction is rejected due to a bad nonce after <see cref="NonceRetries"/> attempts.</exception> internal async Task <BroadcastTxResult> CommitTxAsync(IMessage tx) { BroadcastTxResult result = null; int badNonceCount = 0; do { try { return(await this.TryCommitTxAsync(tx)); } catch (InvalidTxNonceException) { ++badNonceCount; } // WaitForSecondsRealtime can throw a "get_realtimeSinceStartup can only be called from the main thread." error. // WebGL doesn't have threads, so use WaitForSecondsRealtime for WebGL anyway const float delay = 0.5f; #if UNITY_WEBGL && !UNITY_EDITOR await new WaitForSecondsRealtime(delay); #else await Task.Delay(TimeSpan.FromSeconds(delay)); #endif } while ((this.NonceRetries != 0) && (badNonceCount <= this.NonceRetries)); if (badNonceCount > 0) { throw new InvalidTxNonceException(1, "sequence number does not match"); } return(result); }
public void HandleTxResult(BroadcastTxResult result) { for (int i = 0; i < this.Handlers.Length; i++) { this.Handlers[i].HandleTxResult(result); } }
public void HandleTxResult(BroadcastTxResult result) { lock (this.nonceSetLock) { this.NextNonce++; this.Client.Logger.Log($"[NonceLog] Call succeeded, speculating next nonce {this.NextNonce}"); } }
public void HandleTxResult(BroadcastTxResult result) { }