forked from stellar/go
/
queue.go
32 lines (27 loc) · 826 Bytes
/
queue.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package server
import (
"time"
)
// poolTransactionsQueue pools transactions queue which contains only processed and
// validated transactions and sends it to StellarAccountConfigurator for account configuration.
func (s *Server) poolTransactionsQueue() {
s.log.Info("Started pooling transactions queue")
for {
transaction, err := s.TransactionsQueue.QueuePool()
if err != nil {
s.log.WithField("err", err).Error("Error pooling transactions queue")
time.Sleep(time.Second)
continue
}
if transaction == nil {
time.Sleep(time.Second)
continue
}
s.log.WithField("transaction", transaction).Info("Received transaction from transactions queue")
go s.StellarAccountConfigurator.ConfigureAccount(
transaction.StellarPublicKey,
string(transaction.AssetCode),
transaction.Amount,
)
}
}