accounts: list, then subscribe (sub requires active reader)

pull/15526/head
Péter Szilágyi 7 years ago
parent f5091e5711
commit 8a79836044
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
  1. 10
      accounts/manager.go

@ -41,6 +41,11 @@ type Manager struct {
// NewManager creates a generic account manager to sign transaction via various // NewManager creates a generic account manager to sign transaction via various
// supported backends. // supported backends.
func NewManager(backends ...Backend) *Manager { func NewManager(backends ...Backend) *Manager {
// Retrieve the initial list of wallets from the backends and sort by URL
var wallets []Wallet
for _, backend := range backends {
wallets = merge(wallets, backend.Wallets()...)
}
// Subscribe to wallet notifications from all backends // Subscribe to wallet notifications from all backends
updates := make(chan WalletEvent, 4*len(backends)) updates := make(chan WalletEvent, 4*len(backends))
@ -48,11 +53,6 @@ func NewManager(backends ...Backend) *Manager {
for i, backend := range backends { for i, backend := range backends {
subs[i] = backend.Subscribe(updates) subs[i] = backend.Subscribe(updates)
} }
// Retrieve the initial list of wallets from the backends and sort by URL
var wallets []Wallet
for _, backend := range backends {
wallets = merge(wallets, backend.Wallets()...)
}
// Assemble the account manager and return // Assemble the account manager and return
am := &Manager{ am := &Manager{
backends: make(map[reflect.Type][]Backend), backends: make(map[reflect.Type][]Backend),

Loading…
Cancel
Save