Remove check for duplicate fee address index.
This check was added to InsertNewTicket pre-emptivly as a sanity check. It is not strictly required because the fee address itself is also checked, and there is no scenario where we would expect a fee address and its index not to match. Removing this check eases the route forward to improving database performance.
This commit is contained in:
parent
4858af2682
commit
b92c31861f
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2020 The Decred developers
|
||||
// Copyright (c) 2020-2021 The Decred developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
@ -81,6 +81,8 @@ var (
|
||||
ErrNoTicketFound = errors.New("no ticket found")
|
||||
)
|
||||
|
||||
// InsertNewTicket will insert the provided ticket into the database. Returns an
|
||||
// error if either the ticket hash or fee address already exist.
|
||||
func (vdb *VspDatabase) InsertNewTicket(ticket Ticket) error {
|
||||
vdb.ticketsMtx.Lock()
|
||||
defer vdb.ticketsMtx.Unlock()
|
||||
@ -106,10 +108,6 @@ func (vdb *VspDatabase) InsertNewTicket(ticket Ticket) error {
|
||||
return fmt.Errorf("ticket with fee address %s already exists", t.FeeAddress)
|
||||
}
|
||||
|
||||
if t.FeeAddressIndex == ticket.FeeAddressIndex {
|
||||
return fmt.Errorf("ticket with fee address index %d already exists", t.FeeAddressIndex)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@ -190,6 +188,9 @@ func (vdb *VspDatabase) GetTicketByHash(ticketHash string) (Ticket, bool, error)
|
||||
return ticket, found, err
|
||||
}
|
||||
|
||||
// CountTickets returns the total number of voted, revoked, and currently voting
|
||||
// tickets. Requires deserializing every ticket in the db so should be used
|
||||
// sparingly.
|
||||
func (vdb *VspDatabase) CountTickets() (int64, int64, int64, error) {
|
||||
vdb.ticketsMtx.RLock()
|
||||
defer vdb.ticketsMtx.RUnlock()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user