Skip to content

Commit

Permalink
Start work to detach publication
Browse files Browse the repository at this point in the history
  • Loading branch information
linas committed Oct 29, 2019
1 parent 851d8b3 commit 84a94e5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions opencog/persist/ipfs/IPFSAtomStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class IPFSAtomStorage : public BackingStore
bool connected(void); // connection to DB is alive
std::string get_ipfs_cid(void);
std::string get_ipns_key(void);
void publish_atomspace(void);
void resolve_atomspace(void);

std::string get_atom_guid(const Handle&);
Expand Down
10 changes: 10 additions & 0 deletions opencog/persist/ipfs/IPFSPersistSCM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void IPFSPersistSCM::init(void)
define_scheme_primitive("ipfs-load-atomspace", &IPFSPersistSCM::do_load_atomspace, this, "persist-ipfs");
define_scheme_primitive("ipfs-atomspace-cid", &IPFSPersistSCM::do_ipfs_atomspace, this, "persist-ipfs");
define_scheme_primitive("ipns-atomspace-cid", &IPFSPersistSCM::do_ipns_atomspace, this, "persist-ipfs");
define_scheme_primitive("ipfs-publish-atomspace", &IPFSPersistSCM::do_publish_atomspace, this, "persist-ipfs");
define_scheme_primitive("ipfs-resolve-atomspace", &IPFSPersistSCM::do_resolve_atomspace, this, "persist-ipfs");
}

Expand Down Expand Up @@ -162,6 +163,15 @@ std::string IPFSPersistSCM::do_ipns_atomspace(void)
return _backing->get_ipns_key();
}

void IPFSPersistSCM::do_publish_atomspace(void)
{
if (nullptr == _backing)
throw RuntimeException(TRACE_INFO,
"ipns-atomspace: Error: Database not open");

return _backing->publish_atomspace();
}

void IPFSPersistSCM::do_resolve_atomspace(void)
{
if (nullptr == _backing)
Expand Down
1 change: 1 addition & 0 deletions opencog/persist/ipfs/IPFSPersistSCM.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class IPFSPersistSCM
void do_load_atomspace(const std::string&);
std::string do_ipfs_atomspace(void);
std::string do_ipns_atomspace(void);
void do_publish_atomspace(void);
void do_resolve_atomspace(void);

void do_stats(void);
Expand Down
25 changes: 21 additions & 4 deletions opencog/scm/opencog/persist-ipfs.scm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

(export ipfs-clear-stats ipfs-close ipfs-open ipfs-stats
ipfs-atom-cid ipfs-fetch-atom ipfs-load-atomspace
ipfs-atomspace-cid ipns-atomspace-cid ipfs-resolve-atomspace)
ipfs-atomspace-cid ipns-atomspace-cid
ipfs-publish-atomspace ipfs-resolve-atomspace)

(set-procedure-property! ipfs-clear-stats 'documentation
"
Expand Down Expand Up @@ -125,12 +126,28 @@
scheme command `(ipfs-atomspace-cid)` is returning.
")

(set-procedure-property! ipfs-publish-atomspace 'documentation
"
ipfs-publish-atomspace - Publish the current AtomSpace to IPNS.
This allows other users to discover the current AtomSpace CID
by performing an IPNS resolution. Use the
`(ipfs-resolve-atomspace)` to perform this resolution.
Caution: In the current version of IPFS, publishing can take
90 seconds or more. This is a well-known IPFS bug; see
https://github.com/ipfs/go-ipfs/issues/3860
for current status.
")

(set-procedure-property! ipfs-resolve-atomspace 'documentation
"
ipfs-resolve-atomspace - Perform IPNS resolution to get the
current CID of the current AtomSpace. Once resolved, Atoms
in that AtomSpace can be directly accessed.
current CID of the current AtomSpace. The IPNS name must
have been previously published by using the
`(ipfs-publish-atomspace)` function.
Caution: In the current version of IPFS, resolution can take
60 seconds of more. This is a well-known IPFS bug.
60 seconds or more. This is a well-known IPFS bug; see
https://github.com/ipfs/go-ipfs/issues/3860
for current status.
")
3 changes: 2 additions & 1 deletion tests/persist/ipfs/FetchUTest.cxxtest
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ void FetchUTest::test_stuff(void)
delete _as;
_as = new AtomSpace();
eval = SchemeEval::get_evaluator(_as);
eval->eval("(ipfs-open \"ipfs://" + final_atomspace_cid + "\")");
eval->eval(ipfs_open);
eval->eval("(ipfs-resolve-atomspace)");
eval->eval(R"((fetch-atom (List (Concept "AAA") (Concept "BBB"))))");

// The above should NOT update the TV of (Concept "AAA")
Expand Down

0 comments on commit 84a94e5

Please sign in to comment.