本文整理汇总了Golang中github.com/ipfs/go-ipfs/repo/fsrepo/serialize.Load函数的典型用法代码示例。如果您正苦于以下问题:Golang Load函数的具体用法?Golang Load怎么用?Golang Load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Load函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetPeerID
// GetPeerID reads the config of node 'n' and returns its peer ID
func GetPeerID(n int) (string, error) {
cfg, err := serial.Load(path.Join(IpfsDirN(n), "config"))
if err != nil {
return "", err
}
return cfg.Identity.PeerID, nil
}
开发者ID:thomas-gardner,项目名称:go-ipfs,代码行数:8,代码来源:main.go
示例2: openConfig
// openConfig returns an error if the config file is not present.
func (r *FSRepo) openConfig() error {
configFilename, err := config.Filename(r.path)
if err != nil {
return err
}
conf, err := serialize.Load(configFilename)
if err != nil {
return err
}
r.config = conf
return nil
}
开发者ID:heems,项目名称:go-ipfs,代码行数:13,代码来源:fsrepo.go
示例3: ConfigAt
// ConfigAt returns an error if the FSRepo at the given path is not
// initialized. This function allows callers to read the config file even when
// another process is running and holding the lock.
func ConfigAt(repoPath string) (*config.Config, error) {
// packageLock must be held to ensure that the Read is atomic.
packageLock.Lock()
defer packageLock.Unlock()
configFilename, err := config.Filename(repoPath)
if err != nil {
return nil, err
}
return serialize.Load(configFilename)
}
开发者ID:heems,项目名称:go-ipfs,代码行数:15,代码来源:fsrepo.go
示例4: starBootstrap
func starBootstrap(icfg *initCfg) error {
// '0' node is the bootstrap node
cfgpath := path.Join(IpfsDirN(0), "config")
bcfg, err := serial.Load(cfgpath)
if err != nil {
return err
}
bcfg.Bootstrap = nil
bcfg.Addresses.Swarm = []string{icfg.swarmAddrForPeer(0)}
bcfg.Addresses.API = icfg.apiAddrForPeer(0)
bcfg.Addresses.Gateway = ""
bcfg.Discovery.MDNS.Enabled = icfg.Mdns
err = serial.WriteConfigFile(cfgpath, bcfg)
if err != nil {
return err
}
for i := 1; i < icfg.Count; i++ {
cfgpath := path.Join(IpfsDirN(i), "config")
cfg, err := serial.Load(cfgpath)
if err != nil {
return err
}
ba := fmt.Sprintf("%s/ipfs/%s", bcfg.Addresses.Swarm[0], bcfg.Identity.PeerID)
ba = strings.Replace(ba, "0.0.0.0", "127.0.0.1", -1)
cfg.Bootstrap = []string{ba}
cfg.Addresses.Gateway = ""
cfg.Discovery.MDNS.Enabled = icfg.Mdns
cfg.Addresses.Swarm = []string{
icfg.swarmAddrForPeer(i),
}
cfg.Addresses.API = icfg.apiAddrForPeer(i)
err = serial.WriteConfigFile(cfgpath, cfg)
if err != nil {
return err
}
}
return nil
}
开发者ID:thomas-gardner,项目名称:go-ipfs,代码行数:40,代码来源:main.go
示例5: starBootstrap
func starBootstrap(icfg *initCfg) error {
// '0' node is the bootstrap node
cfgpath := path.Join(IpfsDirN(0), "config")
bcfg, err := serial.Load(cfgpath)
if err != nil {
return err
}
bcfg.Bootstrap = nil
bcfg.Addresses.Swarm = []string{icfg.swarmAddrForPeer(0)}
bcfg.Addresses.API = icfg.apiAddrForPeer(0)
bcfg.Addresses.Gateway = ""
err = serial.WriteConfigFile(cfgpath, bcfg)
if err != nil {
return err
}
for i := 1; i < icfg.Count; i++ {
cfgpath := path.Join(IpfsDirN(i), "config")
cfg, err := serial.Load(cfgpath)
if err != nil {
return err
}
cfg.Bootstrap = []string{fmt.Sprintf("%s/ipfs/%s", bcfg.Addresses.Swarm[0], bcfg.Identity.PeerID)}
cfg.Addresses.Gateway = ""
cfg.Addresses.Swarm = []string{
icfg.swarmAddrForPeer(i),
}
cfg.Addresses.API = icfg.apiAddrForPeer(i)
err = serial.WriteConfigFile(cfgpath, cfg)
if err != nil {
return err
}
}
return nil
}
开发者ID:avbalu,项目名称:go-ipfs,代码行数:36,代码来源:main.go
示例6: clearBootstrapping
func clearBootstrapping(icfg *initCfg) error {
for i := 0; i < icfg.Count; i++ {
cfgpath := path.Join(IpfsDirN(i), "config")
cfg, err := serial.Load(cfgpath)
if err != nil {
return err
}
cfg.Bootstrap = nil
cfg.Addresses.Gateway = ""
cfg.Addresses.Swarm = []string{icfg.swarmAddrForPeer(i)}
cfg.Addresses.API = icfg.apiAddrForPeer(i)
err = serial.WriteConfigFile(cfgpath, cfg)
if err != nil {
return err
}
}
return nil
}
开发者ID:avbalu,项目名称:go-ipfs,代码行数:19,代码来源:main.go
示例7: IpfsStart
func IpfsStart(waitall bool) error {
var addrs []string
n := GetNumNodes()
for i := 0; i < n; i++ {
dir := IpfsDirN(i)
cmd := exec.Command("ipfs", "daemon")
cmd.Dir = dir
cmd.Env = envForDaemon(i)
setupOpt(cmd)
stdout, err := os.Create(path.Join(dir, "daemon.stdout"))
if err != nil {
return err
}
stderr, err := os.Create(path.Join(dir, "daemon.stderr"))
if err != nil {
return err
}
cmd.Stdout = stdout
cmd.Stderr = stderr
err = cmd.Start()
if err != nil {
return err
}
pid := cmd.Process.Pid
fmt.Printf("Started daemon %d, pid = %d\n", i, pid)
err = ioutil.WriteFile(path.Join(dir, "daemon.pid"), []byte(fmt.Sprint(pid)), 0666)
if err != nil {
return err
}
// Make sure node 0 is up before starting the rest so
// bootstrapping works properly
cfg, err := serial.Load(path.Join(IpfsDirN(i), "config"))
if err != nil {
return err
}
maddr := ma.StringCast(cfg.Addresses.API)
_, addr, err := manet.DialArgs(maddr)
if err != nil {
return err
}
addrs = append(addrs, addr)
err = waitOnAPI(cfg.Identity.PeerID, i)
if err != nil {
return err
}
}
if waitall {
for i := 0; i < n; i++ {
err := waitOnSwarmPeers(i)
if err != nil {
return err
}
}
}
return nil
}
开发者ID:thomas-gardner,项目名称:go-ipfs,代码行数:67,代码来源:main.go
注:本文中的github.com/ipfs/go-ipfs/repo/fsrepo/serialize.Load函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论