diff --git a/dbft.go b/dbft.go index 39f72db9..48df7440 100644 --- a/dbft.go +++ b/dbft.go @@ -1,6 +1,7 @@ package dbft import ( + "fmt" "sync" "time" @@ -26,7 +27,7 @@ type ( // using provided options or nil if some of the options are missing or invalid. // H and A generic parameters are used as hash and address representation for // dBFT consensus messages, blocks and transactions. -func New[H Hash](options ...func(config *Config[H])) *DBFT[H] { +func New[H Hash](options ...func(config *Config[H])) (*DBFT[H], error) { cfg := defaultConfig[H]() for _, option := range options { @@ -34,7 +35,7 @@ func New[H Hash](options ...func(config *Config[H])) *DBFT[H] { } if err := checkConfig(cfg); err != nil { - return nil + return nil, fmt.Errorf("invalid config: %w") } d := &DBFT[H]{ @@ -45,7 +46,7 @@ func New[H Hash](options ...func(config *Config[H])) *DBFT[H] { }, } - return d + return d, nil } func (d *DBFT[H]) addTransaction(tx Transaction[H]) {