From 9c839caddfcb4021fe31d803860a20f1f17092a1 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 19 Jul 2021 13:27:58 +0200 Subject: [PATCH] walletdb: add new ErrDryRunRollBack error We need a way to signal that a DB transaction should be rolled back because its changes were a dry-run only. We add a new specific error for that case so the automatic rollback on error in the walletdb.View and walletdb.Update comes to play. But we can still return the result of a dry-run where we need to by inspecting for this specific error. --- walletdb/error.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/walletdb/error.go b/walletdb/error.go index 8d96236..97ef680 100644 --- a/walletdb/error.go +++ b/walletdb/error.go @@ -39,6 +39,10 @@ var ( // ErrInvalid is returned if the specified database is not valid. ErrInvalid = errors.New("invalid database") + + // ErrDryRunRollBack is returned if a database transaction should be + // rolled back because its changes were a dry-run only. + ErrDryRunRollBack = errors.New("dry run only; should roll back") ) // Errors that can occur when beginning or committing a transaction.