Пример #1
0
// TODO: it is unpreferable to mix static and non-static use of Do
func GetChainID(do *definitions.Do) error {
	if do.ChainID == "" {
		nodeClient := client.NewErisNodeClient(do.Chain)
		_, chainId, _, err := nodeClient.ChainId()
		if err != nil {
			return err
		}
		do.ChainID = chainId
		log.WithField("=>", do.ChainID).Info("Using ChainID from Node")
	}

	return nil
}
Пример #2
0
func GetChainID(do *definitions.Do) error {
	if do.ChainID == "" {
		status, err := ChainStatus("node_info", do)
		if err != nil {
			return err
		}

		// Wrangle these returns
		type NodeInfo struct {
			ChainID string `mapstructure:"chain_id" json:"chain_id"`
		}
		var ret NodeInfo
		err = json.Unmarshal([]byte(status), &ret)
		if err != nil {
			return err
		}

		do.ChainID = ret.ChainID
		logger.Infof("Using ChainID from Node =>\t%s\n", do.ChainID)
	}

	return nil
}