func InitFactories(config *FactoryOpts) error {
	factoriesInitOnce.Do(func() {
		if config == nil {
			config = GetDefaultOpts()
		}
		if config.ProviderName == "" {
			config.ProviderName = "SW"
		}
		if config.SwOpts == nil {
			config.SwOpts = GetDefaultOpts().SwOpts
		}
		bccspMap = make(map[string]bccsp.BCCSP)
		if config.SwOpts != nil {
			f := &SWFactory{}
			err := initBCCSP(f, config)
			if err != nil {
				factoriesInitError = fmt.Errorf("[%s]", err)
			}
		}
		var ok bool
		defaultBCCSP, ok = bccspMap[config.ProviderName]
		if !ok {
			factoriesInitError = fmt.Errorf("%s\nCould not find default `%s` BCCSP", factoriesInitError, config.ProviderName)
		}
	})
	return factoriesInitError
}
InitFactories must be called before using factory interfaces
It is acceptable to call with config = nil, in which case
some defaults will get used
Error is returned only if defaultBCCSP cannot be found
package factory
import (
	"fmt"
	"github.com/inklabsfoundation/inkchain/bccsp"
)
type FactoryOpts struct {
	ProviderName string  `mapstructure:"default" json:"default" yaml:"Default"`
	SwOpts       *SwOpts `mapstructure:"SW,omitempty" json:"SW,omitempty" yaml:"SwOpts"`
}