Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add enable pubsub/namesys extra opt #49

Merged
merged 3 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation project(':bridge')
}
6 changes: 3 additions & 3 deletions android/bridge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ android {

dependencies {
implementation "$manifest.global.group_id:$manifest.go_core.android.artifact_id:$rootProject.ext.version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'commons-io:commons-io:2.6'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

apply from: 'publish.gradle'
35 changes: 34 additions & 1 deletion android/bridge/src/main/java/ipfs/gomobile/android/IPFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,36 @@ synchronized public void restart() throws NodeStopException {
try { start(); } catch(NodeStartException ignore) { /* Should never happen */ }
}

/**
* Instantiate the ipfs node with the experimental pubsub feature enabled.
*
* @throws ExtraOptionException If enable the extra option failed
gfanton marked this conversation as resolved.
Show resolved Hide resolved
* @see <a href="https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipfs-pubsub">Experimental features of IPFS</a>
*/
synchronized public void enablePubsubExperiment() throws ExtraOptionException {
try {
openRepoIfClosed();
repo.enablePubsubExperiment();
} catch (Exception e) {
throw new ExtraOptionException("Enable pubsub experiment failed", e);
}
}

/**
* Enable IPNS record distribution through pubsub; enables pubsub.
*
gfanton marked this conversation as resolved.
Show resolved Hide resolved
* @throws ExtraOptionException If enable the extra option failed
* @see <a href="https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipns-pubsub">Experimental features of IPFS</a>
*/
synchronized public void enableNamesysPubsub() throws ExtraOptionException {
try {
openRepoIfClosed();
repo.enableNamesysPubsub();
} catch (Exception e) {
throw new ExtraOptionException("Enable namesys pubsub failed", e);
}
}

/**
* Gets the IPFS instance config as a JSON.
*
Expand Down Expand Up @@ -332,8 +362,11 @@ synchronized private void openRepoIfClosed() throws RepoOpenException {
}
}


// Exceptions
public static class ExtraOptionException extends Exception {
ExtraOptionException(String message, Throwable err) { super(message, err); }
}

public static class ConfigCreationException extends Exception {
ConfigCreationException(String message, Throwable err) { super(message, err); }
}
Expand Down
10 changes: 3 additions & 7 deletions go/bind/core/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
mobile_node "github.com/ipfs-shipyard/gomobile-ipfs/go/pkg/node"

ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"

ipfs_bs "github.com/ipfs/go-ipfs/core/bootstrap"
// ipfs_log "github.com/ipfs/go-log"
Expand Down Expand Up @@ -92,15 +92,11 @@ func (n *Node) ServeMultiaddr(smaddr string) (string, error) {
func NewNode(r *Repo) (*Node, error) {
ctx := context.Background()

if _, err := loadPlugins(r.path); err != nil {
if _, err := loadPlugins(r.mr.Path); err != nil {
return nil, err
}

repo := &mobile_node.MobileRepo{
Repo: r.irepo,
Path: r.path,
}
mnode, err := mobile_node.NewNode(ctx, repo, &mobile_host.MobileConfig{})
mnode, err := mobile_node.NewNode(ctx, r.mr, &mobile_host.MobileConfig{})
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go/bind/core/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
)

func TestNode(t *testing.T) {
Expand Down
29 changes: 21 additions & 8 deletions go/bind/core/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package core
import (
"path/filepath"

"github.com/ipfs-shipyard/gomobile-ipfs/go/pkg/node"
ipfs_loader "github.com/ipfs/go-ipfs/plugin/loader"
ipfs_repo "github.com/ipfs/go-ipfs/repo"
ipfs_fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
Expand All @@ -11,8 +12,7 @@ import (
var plugins *ipfs_loader.PluginLoader

type Repo struct {
irepo ipfs_repo.Repo
path string
mr *node.MobileRepo
}

func RepoIsInitialized(path string) bool {
Expand All @@ -37,19 +37,32 @@ func OpenRepo(path string) (*Repo, error) {
return nil, err
}

return &Repo{irepo, path}, nil
mRepo := &node.MobileRepo{
Repo: irepo,
Path: path,
}

return &Repo{mRepo}, nil
}

func (r *Repo) EnablePubsubExperiment() {
r.mr.EnablePubsubExperiment = true
}

func (r *Repo) EnableNamesysPubsub() {
r.mr.EnableNamesysPubsub = true
}

func (r *Repo) GetRootPath() string {
return r.path
return r.mr.Path
}

func (r *Repo) SetConfig(c *Config) error {
return r.irepo.SetConfig(c.getConfig())
return r.mr.Repo.SetConfig(c.getConfig())
}

func (r *Repo) GetConfig() (*Config, error) {
cfg, err := r.irepo.Config()
cfg, err := r.mr.Repo.Config()
if err != nil {
return nil, err
}
Expand All @@ -58,11 +71,11 @@ func (r *Repo) GetConfig() (*Config, error) {
}

func (r *Repo) Close() error {
return r.irepo.Close()
return r.mr.Close()
}

func (r *Repo) getRepo() ipfs_repo.Repo {
return r.irepo
return r.mr
}

func loadPlugins(repoPath string) (*ipfs_loader.PluginLoader, error) {
Expand Down
24 changes: 7 additions & 17 deletions go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@ go 1.14

require (
github.com/ipfs/go-ipfs v0.6.0
github.com/ipfs/go-ipfs-api v0.1.0
github.com/ipfs/go-ipfs-config v0.9.0
github.com/ipfs/interface-go-ipfs-core v0.4.0 // indirect
github.com/libp2p/go-libp2p v0.10.2
github.com/ipfs/go-ipfs-api v0.2.0
github.com/ipfs/go-ipfs-config v0.8.0
github.com/libp2p/go-libp2p v0.9.6
github.com/libp2p/go-libp2p-core v0.6.1
github.com/libp2p/go-libp2p-kad-dht v0.8.3 // indirect
github.com/libp2p/go-libp2p-pubsub v0.3.3 // indirect
github.com/libp2p/go-mplex v0.1.3 // indirect
github.com/multiformats/go-multiaddr v0.2.2
github.com/multiformats/go-multiaddr-net v0.1.5
github.com/libp2p/go-libp2p-pubsub v0.3.5 // indirect
github.com/libp2p/go-libp2p-quic-transport v0.8.0 // indirect
github.com/multiformats/go-multiaddr v0.3.0
github.com/pkg/errors v0.9.1
github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1 // indirect
github.com/whyrusleeping/cbor-gen v0.0.0-20200723185710-6a3894a6352b // indirect
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de // indirect
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1 // indirect
)

replace (
github.com/go-critic/go-critic v0.0.0-20181204210945-ee9bf5809ead => github.com/go-critic/go-critic v0.3.5-0.20190526074819-1df300866540
github.com/golangci/golangci-lint => github.com/golangci/golangci-lint v1.18.0
)
replace github.com/lucas-clemente/quic-go => github.com/lucas-clemente/quic-go v0.18.0 // required by go1.15
Loading