Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter Datapod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
Duniter Datapod
Commits
d3b47dfd
Commit
d3b47dfd
authored
8 months ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
demonstrate subset of remote rpc api
parent
b1558056
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scripts/rpcDatapod.ts
+32
-0
32 additions, 0 deletions
src/scripts/rpcDatapod.ts
with
32 additions
and
0 deletions
src/scripts/rpcDatapod.ts
0 → 100644
+
32
−
0
View file @
d3b47dfd
import
{
create
}
from
'
kubo-rpc-client
'
import
type
{
KuboRPCClient
}
from
'
kubo-rpc-client
'
import
{
Agent
}
from
'
http
'
import
{
EMPTY_NODE_CID
}
from
'
../consts
'
// this script demonstrate the use of a subset of the API served through nginx
// allows to use a remote node without admin privilege on it
const
KUBO_RPC
=
'
https://rpc.datapod.gyroi.de/
'
const
kubo
:
KuboRPCClient
=
create
({
url
:
new
URL
(
KUBO_RPC
),
agent
:
new
Agent
({
maxSockets
:
50000
})
})
async
function
doit
()
{
// getting works
const
n
=
(
await
kubo
.
dag
.
get
(
EMPTY_NODE_CID
)).
value
console
.
log
(
n
)
// putting works
const
obj
=
{
kind
:
123456
,
value
:
"
this is a text I'm going to publish
"
,
something
:
[
1
,
2
,
3
]
}
const
cid
=
await
kubo
.
dag
.
put
(
obj
)
console
.
log
(
cid
)
// pubsub publish works
const
enc
=
new
TextEncoder
()
await
kubo
.
pubsub
.
publish
(
'
ddd
'
,
enc
.
encode
(
"
hello, I'm there
\n
"
))
console
.
log
(
'
published ;)
'
)
}
doit
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment