func New(conf *config.Config) (*ChainDispatcher, error) {
dispatcher := ChainDispatcher{
registry: make(map[ChainType]chain.IChainAdaptor),
}
chainAdaptorFactoryMap := map[string]func(conf *config.Config) (chain.IChainAdaptor, error){
ethereum.ChainName: ethereum.NewChainAdaptor,
}
supportedChains := []string{
ethereum.ChainName,
}
for _, c := range conf.Chains {
if factory, ok := chainAdaptorFactoryMap[c]; ok {
adaptor, err := factory(conf)
if err != nil {
log.Crit("failed to setup chain", "chain", c, "error", err)
}
dispatcher.registry[c] = adaptor
} else {
log.Error("unsupported chain", "chain", c, "supportedChains", supportedChains)
}
}
return &dispatcher, nil
}
上面这个方法中,下面这一句感觉看不明白。 func的conf 是具体如何作用到NewChainAdaptor里面的,感觉也没有对其设置值
chainAdaptorFactoryMap := map[string]func(conf *config.Config) (chain.IChainAdaptor, error){
ethereum.ChainName: ethereum.NewChainAdaptor,
}