Make config fields public
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
parent
51f38e0542
commit
34b6da7f0c
@ -38,10 +38,10 @@ var _ Repo = &MemRepo{}
|
|||||||
|
|
||||||
// MemRepoOptions contains options for memory repo
|
// MemRepoOptions contains options for memory repo
|
||||||
type MemRepoOptions struct {
|
type MemRepoOptions struct {
|
||||||
ds datastore.Datastore
|
Ds datastore.Datastore
|
||||||
configF func() *config.Root
|
ConfigF func() *config.Root
|
||||||
libp2pKey crypto.PrivKey
|
Libp2pKey crypto.PrivKey
|
||||||
wallet interface{}
|
Wallet interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMemory creates new memory based repo with provided options.
|
// NewMemory creates new memory based repo with provided options.
|
||||||
@ -51,27 +51,27 @@ func NewMemory(opts *MemRepoOptions) *MemRepo {
|
|||||||
if opts == nil {
|
if opts == nil {
|
||||||
opts = &MemRepoOptions{}
|
opts = &MemRepoOptions{}
|
||||||
}
|
}
|
||||||
if opts.configF == nil {
|
if opts.ConfigF == nil {
|
||||||
opts.configF = config.Default
|
opts.ConfigF = config.Default
|
||||||
}
|
}
|
||||||
if opts.ds == nil {
|
if opts.Ds == nil {
|
||||||
opts.ds = dssync.MutexWrap(datastore.NewMapDatastore())
|
opts.Ds = dssync.MutexWrap(datastore.NewMapDatastore())
|
||||||
}
|
}
|
||||||
if opts.libp2pKey == nil {
|
if opts.Libp2pKey == nil {
|
||||||
pk, _, err := crypto.GenerateEd25519Key(rand.Reader)
|
pk, _, err := crypto.GenerateEd25519Key(rand.Reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
opts.libp2pKey = pk
|
opts.Libp2pKey = pk
|
||||||
}
|
}
|
||||||
|
|
||||||
return &MemRepo{
|
return &MemRepo{
|
||||||
repoLock: make(chan struct{}, 1),
|
repoLock: make(chan struct{}, 1),
|
||||||
|
|
||||||
datastore: opts.ds,
|
datastore: opts.Ds,
|
||||||
configF: opts.configF,
|
configF: opts.ConfigF,
|
||||||
libp2pKey: opts.libp2pKey,
|
libp2pKey: opts.Libp2pKey,
|
||||||
wallet: opts.wallet,
|
wallet: opts.Wallet,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user