Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The Interactive tutorial has been updated: https://starboard.gg/nb/nl2QbJ2
<script src="https://cdn.jsdelivr.net/npm/gun/lib/radisk.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/lib/store.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/lib/rindexed.js"></script>
<script src="https://skynet-js.hns.siasky.net/4.0-beta/index.js"></script>
<script src="https://skynet-js.hns.siasky.net/4.1/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/zenbase/src/index.js"></script>
<script>
let hello_world = ""
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"author": "fluffy9",
"license": "MIT",
"dependencies": {
"gun": "^0.2020.1235",
"skynet-js": "^3.0.2"
"gun": "^0.2020.1236",
"skynet-js": "^4.1.0"
}
}
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ function factory(opt) {
store.put = function (key, data, cb) {
// if the debug setting is on, print the key and the data we're storing to skynet, and pause execution using debugger statement
if (debug) {
console.log('[Put] \nKey: ' + key + " \nData: " + JSON.stringify(data));
console.log('>>> [Put] \n>>> Key: ' + key + " \n>>> Data: " + data);
debugger
}
// if there is data to be stored, pass that data to skynet
if (data) {
// save the json to skynet. We will pass in null to cb since we're not returning anything
client.db.setJSON(privateKey, key, data).then(() => {cb(null,1)}).catch(err => {
client.db.setJSON(privateKey, key, JSON.parse(data)).then(() => {cb(null,1)}).catch(err => {
// if there is an error and debugging is on, make it easier to debug
// gun throws a lot of errors even if it succeeds though ¯\_(ツ)_/¯
if (debug) {
console.log('Put Error: ', JSON.stringify(err))
console.log('>>> Put Error: ', JSON.stringify(err))
debugger
}
// return the error
Expand All @@ -56,20 +56,20 @@ function factory(opt) {
store.get = function (key, cb) {
// if the debug setting is on, print the key we're using to retrieve from skynet, and pause execution using debugger statement
if (debug) {
console.log('[Get] \nKey: ' + key);
console.log('>>> [Get] \nKey: ' + key);
debugger
}
// ask skynet for the data
client.db.getJSON(publicKey, key).then(data => {
// if we're debugging, log the data we retrieved
if (debug) { console.log("Retrieved Data: " + JSON.stringify(data)); }
if (debug) { console.log(">>> Retrieved Data: " + JSON.stringify(data)); }
// Pass the data back to gun. In the case where the data returned is null or something we'll return undefined
if (!data['data']['!']) {cb(null, JSON.stringify(data['data']) || undefined)} else { cb(null, undefined)} })
.catch((err) => {
// if there is an error and debugging is on, make it easier to debug
// gun throws a lot of errors even if it succeeds though ¯\_(ツ)_/¯
if (debug) {
console.log('Get Error: ', JSON.stringify(err))
console.log('>>> Get Error: ', JSON.stringify(err))
debugger
}
// return nothing
Expand Down