unique refund account ids

This commit is contained in:
Radu Ioan Fericean
2016-01-06 14:29:11 +02:00
parent 382f4c308d
commit 731a33b3bd

View File

@@ -745,10 +745,15 @@ func (cd *CallDescriptor) RefundIncrements() (left float64, err error) {
cd.account = nil // make sure it's not cached
// get account list for locking
// all must be locked in order to use cache
accMap := make(map[string]struct{})
var accountIDs []string
for _, increment := range cd.Increments {
accountIDs = append(accountIDs, increment.BalanceInfo.AccountId)
accMap[increment.BalanceInfo.AccountId] = struct{}{}
}
for key := range accMap {
accountIDs = append(accountIDs, key)
}
// start increment refunding loop
Guardian.Guard(func() (interface{}, error) {
accountsCache := make(map[string]*Account)
for _, increment := range cd.Increments {