diff --git a/liquidity/liquidity.go b/liquidity/liquidity.go index bc5be2a..0829363 100644 --- a/liquidity/liquidity.go +++ b/liquidity/liquidity.go @@ -45,6 +45,12 @@ const ( ) var ( + // defaultParameters contains the default parameters that we start our + // liquidity manger with. + defaultParameters = Parameters{ + ChannelRules: make(map[lnwire.ShortChannelID]*ThresholdRule), + } + // ErrZeroChannelID is returned if we get a rule for a 0 channel ID. ErrZeroChannelID = fmt.Errorf("zero channel ID not allowed") ) @@ -71,13 +77,6 @@ type Parameters struct { ChannelRules map[lnwire.ShortChannelID]*ThresholdRule } -// newParameters creates an empty set of parameters. -func newParameters() Parameters { - return Parameters{ - ChannelRules: make(map[lnwire.ShortChannelID]*ThresholdRule), - } -} - // String returns the string representation of our parameters. func (p Parameters) String() string { channelRules := make([]string, 0, len(p.ChannelRules)) @@ -127,7 +126,7 @@ type Manager struct { func NewManager(cfg *Config) *Manager { return &Manager{ cfg: cfg, - params: newParameters(), + params: defaultParameters, } } diff --git a/liquidity/liquidity_test.go b/liquidity/liquidity_test.go index 36492b8..cba9ca3 100644 --- a/liquidity/liquidity_test.go +++ b/liquidity/liquidity_test.go @@ -73,7 +73,7 @@ func TestParameters(t *testing.T) { // Start with the case where we have no rules set. startParams := manager.GetParameters() - require.Equal(t, newParameters(), startParams) + require.Equal(t, defaultParameters, startParams) // Mutate the parameters returned by our get function. startParams.ChannelRules[chanID] = NewThresholdRule(1, 1) @@ -81,15 +81,14 @@ func TestParameters(t *testing.T) { // Make sure that we have not mutated the liquidity manager's params // by making this change. params := manager.GetParameters() - require.Equal(t, newParameters(), params) + require.Equal(t, defaultParameters, params) // Provide a valid set of parameters and validate assert that they are // set. originalRule := NewThresholdRule(10, 10) - expected := Parameters{ - ChannelRules: map[lnwire.ShortChannelID]*ThresholdRule{ - chanID: originalRule, - }, + expected := defaultParameters + expected.ChannelRules = map[lnwire.ShortChannelID]*ThresholdRule{ + chanID: originalRule, } err := manager.SetParameters(expected)