Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libre
Samizdat
Commits
1aaea188
Commit
1aaea188
authored
Oct 05, 2020
by
Michał Woźniak
Browse files
debugging gun-ipfs
parent
bf7c505c
Changes
2
Hide whitespace changes
Inline
Side-by-side
config.js
View file @
1aaea188
...
...
@@ -11,7 +11,7 @@
self
.
SamizdatConfig
.
plugins
=
{
'
fetch
'
:{},
'
cache
'
:{},
'
any-of
'
:
{
/*
'any-of': {
plugins: {
'alt-fetch':{
// configuring the alternate endpoints plugin to use IPNS gateways
...
...
@@ -25,10 +25,13 @@ self.SamizdatConfig.plugins = {
'https://gateway.temporal.cloud/ipns/QmYGVgGGfD5N4Xcc78CcMJ99dKcH6K6myhd4Uenv5yJwiJ/', // Germany
'https://ipfs.best-practice.se/ipns/QmYGVgGGfD5N4Xcc78CcMJ99dKcH6K6myhd4Uenv5yJwiJ/' // Sweden
]
},
},
*/
'
gun-ipfs
'
:
{
gunPubkey
:
'
WUK5ylwqqgUorceQRa84qfbBFhk7eNRDUoPbGK05SyE.-yohFhTzWPpDT-UDMuKGgemOUrw_cMMYWpy6plILqrg
'
}
}
}
//
}
//
}
}
// debugging self.log()
self
.
SamizdatConfig
.
loggedComponents
=
[
'
gun-ipfs
'
]
plugins/gun-ipfs.js
View file @
1aaea188
...
...
@@ -53,7 +53,9 @@
*/
function
doImport
()
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
self
.
log
(
config
.
name
,
`doImport()\n+--
${
args
.
join
(
'
\n
+--
'
)}
`
)
if
(
typeof
self
.
importScripts
!==
'
undefined
'
)
{
self
.
log
(
config
.
name
,
`+-- self.importScripts.apply()`
)
self
.
importScripts
.
apply
(
self
,
args
)
}
else
{
self
.
log
(
...
...
@@ -77,26 +79,36 @@
}
async
function
setup_gun
()
{
self
.
log
(
config
.
name
,
'
setup_gun()
'
)
if
(
gun
===
undefined
)
{
gun
=
false
// we don't want to start a few times over
self
.
log
(
config
.
name
,
'
importing Gun-related libraries...
'
);
doImport
(
"
./lib/gun.js
"
,
"
./lib/sea.js
"
,
"
./lib/webrtc.js
"
);
try
{
doImport
(
"
./lib/gun.js
"
,
"
./lib/sea.js
"
/*,
"./lib/webrtc.js"*/
);
}
catch
(
e
)
{
console
.
error
(
e
)
}
self
.
log
(
config
.
name
,
'
setting up Gun...
'
)
gun
=
Gun
([
'
https://gunjs.herokuapp.com/gun
'
,
'
https://samizdat.is/gun
'
]);
self
.
log
(
config
.
name
,
'
+-- gun loaded :: gun is :
'
+
typeof
gun
);
}
if
(
(
gun
!==
false
)
&&
(
gun
!==
undefined
)
&&
(
gunUser
===
undefined
)
)
{
gunUser
=
false
// we don't want to start a few times over
self
.
log
(
config
.
name
,
'
setting up gunUser...
'
)
gunUser
=
gun
.
user
(
config
.
gunPubkey
)
self
.
log
(
config
.
name
,
'
+-- gun init complete :: gunUser is:
'
+
typeof
gunUser
);
if
(
(
gun
!==
false
)
&&
(
gun
!==
undefined
)
)
{
if
(
gunUser
===
undefined
)
{
gunUser
=
false
// we don't want to start a few times over
self
.
log
(
config
.
name
,
'
setting up gunUser...
'
)
gunUser
=
gun
.
user
(
config
.
gunPubkey
)
self
.
log
(
config
.
name
,
'
+-- gun init complete :: gunUser is:
'
+
typeof
gunUser
);
}
}
else
{
console
.
error
(
"
at this point Gun should have been set up already, but isn't!
"
)
}
}
async
function
setup_gun_ipfs
()
{
self
.
log
(
config
.
name
,
'
setup_gun_ipfs()
'
)
if
(
ipfs
===
undefined
||
gun
===
undefined
)
{
self
.
log
(
config
.
name
,
'
setting up...
'
)
setup_ipfs
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment