Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed Jun 13, 2024
1 parent 642b4a3 commit ad64425
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions go/enclave/storage/enclavedb/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func MarkBatchExecuted(ctx context.Context, dbtx *sql.Tx, seqNo *big.Int) error
return err
}

func WriteExecutedTransaction(ctx context.Context, dbtx *sql.Tx, batchSeqNo uint64, txId uint64, createdContract *uint64, receipt []byte) (uint64, error) {
func WriteExecutedTransaction(ctx context.Context, dbtx *sql.Tx, batchSeqNo uint64, txId *uint64, createdContract *uint64, receipt []byte) (uint64, error) {
insert := "insert into exec_tx (created_contract_address, receipt, tx, batch) values " + "(?,?,?,?)"
res, err := dbtx.ExecContext(ctx, insert, createdContract, receipt, txId, batchSeqNo)
if err != nil {
Expand All @@ -129,10 +129,17 @@ func WriteExecutedTransaction(ctx context.Context, dbtx *sql.Tx, batchSeqNo uint
return uint64(id), nil
}

func GetTxId(ctx context.Context, dbtx *sql.Tx, txHash gethcommon.Hash) (uint64, error) {
func GetTxId(ctx context.Context, dbtx *sql.Tx, txHash gethcommon.Hash) (*uint64, error) {
var txId uint64
err := dbtx.QueryRowContext(ctx, "select id from tx where hash=? ", txHash.Bytes()).Scan(&txId)
return txId, err
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
// make sure the error is converted to obscuro-wide not found error
return nil, errutil.ErrNotFound
}
return nil, err
}
return &txId, err
}

func ReadBatchHeaderBySeqNo(ctx context.Context, db *sql.DB, seqNo uint64) (*common.BatchHeader, error) {
Expand Down
2 changes: 1 addition & 1 deletion go/enclave/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ func (s *storageImpl) storeReceiptAndEventLogs(ctx context.Context, dbTX *sql.Tx
}

txId, err := enclavedb.GetTxId(ctx, dbTX, receipt.TxHash)
if err != nil {
if err != nil && !errors.Is(err, errutil.ErrNotFound) {
return fmt.Errorf("could not get transaction id. Cause: %w", err)
}

Expand Down

0 comments on commit ad64425

Please sign in to comment.