Added debit settlement amount calculation

This commit is contained in:
Stephan D
2026-02-06 17:50:11 +01:00
parent 17bc2a2a62
commit c8b8b1183b
44 changed files with 200 additions and 242 deletions

View File

@@ -0,0 +1,36 @@
package shared
import "strings"
// NetworkRegistry provides network configuration lookup by name.
type NetworkRegistry struct {
networks map[string]Network
}
// NewNetworkRegistry creates a NetworkRegistry from a slice of network configs.
func NewNetworkRegistry(networks []Network) *NetworkRegistry {
m := make(map[string]Network, len(networks))
for _, n := range networks {
if n.Name.IsValid() {
m[strings.ToLower(n.Name.String())] = n
}
}
return &NetworkRegistry{networks: m}
}
// Network returns the configuration for the named network.
func (r *NetworkRegistry) Network(name string) (Network, bool) {
if r == nil || r.networks == nil {
return Network{}, false
}
n, ok := r.networks[strings.ToLower(strings.TrimSpace(name))]
return n, ok
}
// Networks returns all configured networks.
func (r *NetworkRegistry) Networks() map[string]Network {
if r == nil {
return nil
}
return r.networks
}