本文整理汇总了Golang中github.com/ipfs/go-ipfs/repo/config.Init函数的典型用法代码示例。如果您正苦于以下问题:Golang Init函数的具体用法?Golang Init怎么用?Golang Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Init函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: doInit
func doInit(out io.Writer, repoRoot string, force bool, nBitsForKeypair int) error {
if _, err := fmt.Fprintf(out, "initializing ipfs node at %s\n", repoRoot); err != nil {
return err
}
if err := checkWriteable(repoRoot); err != nil {
return err
}
if fsrepo.IsInitialized(repoRoot) && !force {
return errRepoExists
}
conf, err := config.Init(out, nBitsForKeypair)
if err != nil {
return err
}
if fsrepo.IsInitialized(repoRoot) {
if err := fsrepo.Remove(repoRoot); err != nil {
return err
}
}
if err := fsrepo.Init(repoRoot, conf); err != nil {
return err
}
if err := addDefaultAssets(out, repoRoot); err != nil {
return err
}
return initializeIpnsKeyspace(repoRoot)
}
开发者ID:hebelken,项目名称:go-ipfs,代码行数:34,代码来源:init.go
示例2: doInit
func doInit(out io.Writer, repoRoot string, empty bool, nBitsForKeypair int, conf *config.Config) error {
if _, err := fmt.Fprintf(out, "initializing ipfs node at %s\n", repoRoot); err != nil {
return err
}
if err := checkWriteable(repoRoot); err != nil {
return err
}
if fsrepo.IsInitialized(repoRoot) {
return errRepoExists
}
if conf == nil {
var err error
conf, err = config.Init(out, nBitsForKeypair)
if err != nil {
return err
}
}
if err := fsrepo.Init(repoRoot, conf); err != nil {
return err
}
if !empty {
if err := addDefaultAssets(out, repoRoot); err != nil {
return err
}
}
return initializeIpnsKeyspace(repoRoot)
}
开发者ID:Kubuxu,项目名称:go-ipfs,代码行数:33,代码来源:init.go
示例3: doInit
func doInit(out io.Writer, repoRoot string, force bool, empty bool, nBitsForKeypair int) error {
log.Println("initializing ipfs node at ", repoRoot)
if err := checkWriteable(repoRoot); err != nil {
return err
}
if fsrepo.IsInitialized(repoRoot) && !force {
log.Println("repo already exists")
return nil
}
conf, err := config.Init(out, nBitsForKeypair)
if err != nil {
return err
}
if fsrepo.IsInitialized(repoRoot) {
if err := fsrepo.Remove(repoRoot); err != nil {
return err
}
}
if err := fsrepo.Init(repoRoot, conf); err != nil {
return err
}
if !empty {
if err := addDefaultAssets(out, repoRoot); err != nil {
return err
}
}
return initializeIpnsKeyspace(repoRoot)
}
开发者ID:utamaro,项目名称:core,代码行数:35,代码来源:init_repo.go
示例4: startupIPFS
func startupIPFS(dspath string, ctx *context.Context) (*core.IpfsNode, error) {
r, err := fsrepo.Open(dspath)
if err != nil {
config, err := config.Init(os.Stdout, 2048)
if err != nil {
return nil, err
}
if err := fsrepo.Init(dspath, config); err != nil {
return nil, err
}
r, err = fsrepo.Open(dspath)
if err != nil {
return nil, err
}
}
//fmt.Println(r)
node, err := core.NewNode(*ctx, &core.BuildCfg{Online: true, Repo: r})
if err != nil {
return nil, err
}
return node, nil
}
开发者ID:jamesunger,项目名称:ipboh,代码行数:27,代码来源:ipboh.go
示例5: NewTmpDirNode
func NewTmpDirNode(ctx context.Context) (*core.IpfsNode, error) {
dir, err := ioutil.TempDir("", "ipfs-shell")
if err != nil {
return nil, fmt.Errorf("failed to get temp dir: %s", err)
}
cfg, err := config.Init(ioutil.Discard, 1024)
if err != nil {
return nil, err
}
err = fsrepo.Init(dir, cfg)
if err != nil {
return nil, fmt.Errorf("failed to init ephemeral node: %s", err)
}
repo, err := fsrepo.Open(dir)
if err != nil {
return nil, err
}
return core.NewNode(ctx, &core.BuildCfg{
Online: true,
Repo: repo,
})
}
开发者ID:noffle,项目名称:ipfs-embedded-shell,代码行数:26,代码来源:node.go
示例6: runFileCattingWorker
func runFileCattingWorker(ctx context.Context, n *core.IpfsNode) error {
conf, err := config.Init(ioutil.Discard, *nBitsForKeypair)
if err != nil {
return err
}
r := &repo.Mock{
D: ds2.CloserWrap(syncds.MutexWrap(datastore.NewMapDatastore())),
C: *conf,
}
dummy, err := core.NewNode(ctx, &core.BuildCfg{
Repo: r,
})
if err != nil {
return err
}
errs := make(chan error)
go func() {
defer dummy.Close()
var i int64 = 1
for {
buf := new(bytes.Buffer)
if err := random.WritePseudoRandomBytes(sizeOfIthFile(i), buf, *seed); err != nil {
errs <- err
}
// add to a dummy node to discover the key
k, err := coreunix.Add(dummy, bytes.NewReader(buf.Bytes()))
if err != nil {
errs <- err
}
e := elog.EventBegin(ctx, "cat", logging.LoggableF(func() map[string]interface{} {
return map[string]interface{}{
"key": k,
"localPeer": n.Identity,
}
}))
if r, err := coreunix.Cat(ctx, n, k); err != nil {
e.Done()
log.Printf("failed to cat file. seed: %d #%d key: %s err: %s", *seed, i, k, err)
} else {
log.Println("found file", "seed", *seed, "#", i, "key", k, "size", unit.Information(sizeOfIthFile(i)))
io.Copy(ioutil.Discard, r)
e.Done()
log.Println("catted file", "seed", *seed, "#", i, "key", k, "size", unit.Information(sizeOfIthFile(i)))
i++
}
time.Sleep(time.Second)
}
}()
err = <-errs
if err != nil {
log.Fatal(err)
}
return nil
}
开发者ID:Kubuxu,项目名称:go-ipfs,代码行数:59,代码来源:main.go
示例7: ensureRepoInitialized
func ensureRepoInitialized(path string) error {
if !fsrepo.IsInitialized(path) {
conf, err := config.Init(ioutil.Discard, *nBitsForKeypair)
if err != nil {
return err
}
if err := fsrepo.Init(path, conf); err != nil {
return err
}
}
return nil
}
开发者ID:rdterner,项目名称:go-ipfs,代码行数:12,代码来源:main.go
示例8: CreateIpfsRepo
// CreateIpfsRepo initializes an empty .ipfs directory at `ipfsRootPath`.
// ipfsRootPath should contain the ".ipfs" at the end.
func CreateIpfsRepo(ipfsRootPath string) error {
logger := &logutil.Writer{Level: log.InfoLevel}
cfg, err := ipfsconfig.Init(logger, 2048)
if err != nil {
return err
}
if err := fsrepo.Init(ipfsRootPath, cfg); err != nil {
return err
}
return nil
}
开发者ID:disorganizer,项目名称:brig,代码行数:15,代码来源:init.go
示例9: InitRepo
// InitRepo creates an initialized .ipfs directory in the directory `path`.
// The generated RSA key will have `keySize` bits.
func InitRepo(path string, keySize int) (string, error) {
if err := os.MkdirAll(path, 0744); err != nil {
return "", err
}
cfg, err := ipfsconfig.Init(ioutil.Discard, keySize)
if err != nil {
return "", err
}
if err := fsrepo.Init(path, cfg); err != nil {
return "", err
}
return path, nil
}
开发者ID:disorganizer,项目名称:brig,代码行数:18,代码来源:init.go
注:本文中的github.com/ipfs/go-ipfs/repo/config.Init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论