From fbefc13f789ab669ed23bd520bf3ee73c6ec5e22 Mon Sep 17 00:00:00 2001 From: nkostoulas Date: Wed, 2 Oct 2019 17:37:24 +0100 Subject: [PATCH] New isFeeBumped flag to make sure fee bumping is done once --- attestation/attestservice.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/attestation/attestservice.go b/attestation/attestservice.go index df3be89..65f81fd 100644 --- a/attestation/attestservice.go +++ b/attestation/attestservice.go @@ -105,6 +105,8 @@ var ( attestDelay time.Duration // handle state delay confirmTime time.Time // handle confirmation timing + + isFeeBumped bool // flag to keep track if the fee has already been bumped ) // NewAttestService returns a pointer to an AttestService instance @@ -118,6 +120,7 @@ func NewAttestService(ctx context.Context, wg *sync.WaitGroup, server *AttestSer // initiate attestation client attester := NewAttestClient(config) + isFeeBumped = false // initiate timing schedules atimeNewAttestation = DefaultATimeNewAttestation @@ -476,6 +479,7 @@ func (s *AttestService) doStateSendAttestation() { s.state = AStateAwaitConfirmation // update attestation state attestDelay = ATimeConfirmation // add confirmation waiting time confirmTime = time.Now() // set time for awaiting confirmation + isFeeBumped = false // reset fee bumped flag } // AStateAwaitConfirmation @@ -529,9 +533,12 @@ func (s *AttestService) doStateHandleUnconfirmed() { log.Printf("********** bumping fees for attestation txid: %s\n", s.attestation.Tx.TxHash().String()) currentTx := &s.attestation.Tx - bumpErr := s.attester.bumpAttestationFees(currentTx) - if s.setFailure(bumpErr) { - return // will rebound to init + if !isFeeBumped { + bumpErr := s.attester.bumpAttestationFees(currentTx) + if s.setFailure(bumpErr) { + return // will rebound to init + } + isFeeBumped = true } s.attestation.Tx = *currentTx