OSDN Git Service

add error code for veto (#219)
authorwz <mars@bytom.io>
Mon, 24 Jun 2019 06:43:32 +0000 (14:43 +0800)
committerPaladz <yzhu101@uottawa.ca>
Mon, 24 Jun 2019 06:43:31 +0000 (14:43 +0800)
* add error code

* fix

account/utxo_keeper.go
api/errors.go

index cd9beea..ed4d685 100644 (file)
@@ -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
        }
 
index 7c5debd..5391d07 100644 (file)
@@ -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)