From 5050ec8a8ac00351713b219bc897eafc1bfd6293 Mon Sep 17 00:00:00 2001 From: wz Date: Mon, 24 Jun 2019 14:43:32 +0800 Subject: [PATCH] add error code for veto (#219) * add error code * fix --- account/utxo_keeper.go | 4 ++++ api/errors.go | 1 + 2 files changed, 5 insertions(+) diff --git a/account/utxo_keeper.go b/account/utxo_keeper.go index cd9beea6..ed4d685c 100644 --- a/account/utxo_keeper.go +++ b/account/utxo_keeper.go @@ -22,6 +22,7 @@ const desireUtxoCount = 5 var ( ErrInsufficient = errors.New("reservation found insufficient funds") ErrImmature = errors.New("reservation found immature funds") + ErrVoteLock = errors.New("Locked by the vote") ErrReserved = errors.New("reservation found outputs already reserved") ErrMatchUTXO = errors.New("can't find utxo with given hash") ErrReservation = errors.New("couldn't find reservation") @@ -124,6 +125,9 @@ func (uk *utxoKeeper) Reserve(accountID string, assetID *bc.AssetID, amount uint } if optAmount+reservedAmount < amount { + if vote != nil { + return nil, ErrVoteLock + } return nil, ErrImmature } diff --git a/api/errors.go b/api/errors.go index 7c5debdd..5391d070 100644 --- a/api/errors.go +++ b/api/errors.go @@ -71,6 +71,7 @@ var respErrFormatter = map[error]httperror.Info{ txbuilder.ErrOrphanTx: {400, "BTM712", "Transaction input UTXO not found"}, txbuilder.ErrExtTxFee: {400, "BTM713", "Transaction fee exceeded max limit"}, txbuilder.ErrNoGasInput: {400, "BTM714", "Transaction has no gas input"}, + account.ErrVoteLock: {400, "BTM715", "Locked by the vote"}, // Submit transaction error namespace (73x ~ 79x) // Validation error (73x ~ 75x) -- 2.11.0