Skip to content

Commit

Permalink
Update to android 2.0.9 and core 0.7.2 (swarm connect of textileio#108)
Browse files Browse the repository at this point in the history
Signed-off-by: Li Zheng <[email protected]>
  • Loading branch information
flyskywhy committed Sep 30, 2019
1 parent 8e06875 commit 3a9cdb2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion android/manifest.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ ext {
mavenGradleVersion = '2.1'

// Textile
textileVersion = '2.0.8'
textileVersion = '2.0.9'
}
19 changes: 19 additions & 0 deletions android/src/main/java/io/textile/rnmobile/IpfsBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ public void run() {
});
}

@ReactMethod
public void connect(final String multiaddr, final Promise promise) {
executor.execute(new Runnable() {
@Override
public void run() {
try {
if (Textile.instance().ipfs.swarmConnect(multiaddr)) {
promise.resolve(true);
} else {
promise.reject(new Exception("connect"));
}
}
catch (final Exception e) {
promise.reject("connect", e);
}
}
});
}

@ReactMethod
public void dataAtPath(final String path, final Promise promise) {
executor.execute(new Runnable() {
Expand Down
13 changes: 13 additions & 0 deletions src/ipfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ export async function peerId(): Promise<string> {
return result as string
}

/**
* Open a new direct connection to a peer using an IPFS multiaddr
* ```typescript
* Textile.ipfs.connect(multiaddr);
* ```
*/
export async function connect(
multiaddr: string
): Promise<boolean> {
const result = await IpfsBridge.connect(multiaddr)
return result
}

/**
* Get raw file data by IPFS path. See `cat` method in IPFS.
* ```typescript
Expand Down

0 comments on commit 3a9cdb2

Please sign in to comment.