-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Norman Meier <[email protected]>
- Loading branch information
Showing
15 changed files
with
92 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//go:build !js | ||
|
||
package baseorbitdb | ||
|
||
import ( | ||
"fmt" | ||
"path" | ||
|
||
"berty.tech/go-ipfs-log/keystore" | ||
"berty.tech/go-orbit-db/cache/cacheleveldown" | ||
leveldb "github.com/ipfs/go-ds-leveldb" | ||
"github.com/libp2p/go-libp2p/core/peer" | ||
) | ||
|
||
func NewKeystore(id peer.ID, directory string) (*keystore.Keystore, func() error, error) { | ||
var err error | ||
var ds *leveldb.Datastore | ||
|
||
// create new datastore | ||
if directory == cacheleveldown.InMemoryDirectory { | ||
ds, err = leveldb.NewDatastore("", nil) | ||
} else { | ||
ds, err = leveldb.NewDatastore(path.Join(directory, id.String(), "/keystore"), nil) | ||
} | ||
|
||
if err != nil { | ||
return nil, nil, fmt.Errorf("unable to create data store used by keystore: %w", err) | ||
} | ||
|
||
ks, err := keystore.NewKeystore(ds) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("unable to create keystore: %w", err) | ||
} | ||
|
||
return ks, ds.Close, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//go:build js | ||
|
||
package baseorbitdb | ||
|
||
import ( | ||
"errors" | ||
|
||
"berty.tech/go-ipfs-log/keystore" | ||
"github.com/libp2p/go-libp2p/core/peer" | ||
) | ||
|
||
func NewKeystore(id peer.ID, directory string) (*keystore.Keystore, func() error, error) { | ||
return nil, nil, errors.New("can't create default keystore in js") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//go:build js | ||
|
||
package cacheleveldown | ||
|
||
import ( | ||
"berty.tech/go-orbit-db/cache" | ||
) | ||
|
||
var InMemoryDirectory = ":memory:" | ||
|
||
// New Creates a new leveldb data store | ||
func New(opts *cache.Options) cache.Interface { | ||
panic("cacheleveldown not implemented in js") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !js | ||
|
||
package tests | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !js | ||
|
||
package tests | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !js | ||
|
||
package tests | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !js | ||
|
||
package tests | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !js | ||
|
||
package tests | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !js | ||
|
||
package tests | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !js | ||
|
||
package tests | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !js | ||
|
||
package tests | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build !js | ||
|
||
package tests | ||
|
||
import ( | ||
|