Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
6b169819
Commit
6b169819
authored
9 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make the default repo for corebuilder work
parent
0494a4db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
3 deletions
+34
-3
core/builder.go
core/builder.go
+34
-3
No files found.
core/builder.go
View file @
6b169819
package
core
import
(
"crypto/rand"
"encoding/base64"
"errors"
ds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
dsync
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
key
"github.com/ipfs/go-ipfs/blocks/key"
ci
"github.com/ipfs/go-ipfs/p2p/crypto"
repo
"github.com/ipfs/go-ipfs/repo"
cfg
"github.com/ipfs/go-ipfs/repo/config"
)
var
ErrAlreadyBuilt
=
errors
.
New
(
"this builder has already been used"
)
...
...
@@ -28,10 +33,32 @@ func NewNodeBuilder() *NodeBuilder {
}
}
func
defaultRepo
()
repo
.
Repo
{
func
defaultRepo
()
(
repo
.
Repo
,
error
)
{
c
:=
cfg
.
Config
{}
priv
,
pub
,
err
:=
ci
.
GenerateKeyPairWithReader
(
ci
.
RSA
,
1024
,
rand
.
Reader
)
if
err
!=
nil
{
return
nil
,
err
}
data
,
err
:=
pub
.
Hash
()
if
err
!=
nil
{
return
nil
,
err
}
privkeyb
,
err
:=
priv
.
Bytes
()
if
err
!=
nil
{
return
nil
,
err
}
c
.
Bootstrap
=
cfg
.
DefaultBootstrapAddresses
c
.
Addresses
.
Swarm
=
[]
string
{
"/ip4/0.0.0.0/tcp/4001"
}
c
.
Identity
.
PeerID
=
key
.
Key
(
data
)
.
B58String
()
c
.
Identity
.
PrivKey
=
base64
.
StdEncoding
.
EncodeToString
(
privkeyb
)
return
&
repo
.
Mock
{
D
:
dsync
.
MutexWrap
(
ds
.
NewMapDatastore
()),
}
C
:
c
,
},
nil
}
func
(
nb
*
NodeBuilder
)
Online
()
*
NodeBuilder
{
...
...
@@ -65,7 +92,11 @@ func (nb *NodeBuilder) Build(ctx context.Context) (*IpfsNode, error) {
}
nb
.
built
=
true
if
nb
.
repo
==
nil
{
nb
.
repo
=
defaultRepo
()
r
,
err
:=
defaultRepo
()
if
err
!=
nil
{
return
nil
,
err
}
nb
.
repo
=
r
}
conf
:=
standardWithRouting
(
nb
.
repo
,
nb
.
online
,
nb
.
routing
,
nb
.
peerhost
)
return
NewIPFSNode
(
ctx
,
conf
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment