Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
102df6b9
Commit
102df6b9
authored
9 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Fix
#274
Added /network/peers URI
parent
c67077bd
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/network.js
+28
-0
28 additions, 0 deletions
app/controllers/network.js
app/lib/streams/bma.js
+1
-0
1 addition, 0 deletions
app/lib/streams/bma.js
doc/HTTP_API.md
+48
-0
48 additions, 0 deletions
doc/HTTP_API.md
with
77 additions
and
0 deletions
app/controllers/network.js
+
28
−
0
View file @
102df6b9
"
use strict
"
;
"
use strict
"
;
var
_
=
require
(
'
underscore
'
);
var
co
=
require
(
'
co
'
);
var
async
=
require
(
'
async
'
);
var
async
=
require
(
'
async
'
);
var
es
=
require
(
'
event-stream
'
);
var
es
=
require
(
'
event-stream
'
);
var
dos2unix
=
require
(
'
../lib/dos2unix
'
);
var
dos2unix
=
require
(
'
../lib/dos2unix
'
);
...
@@ -72,4 +74,30 @@ function NetworkBinding (server, conf) {
...
@@ -72,4 +74,30 @@ function NetworkBinding (server, conf) {
.
pipe
(
es
.
stringify
())
.
pipe
(
es
.
stringify
())
.
pipe
(
res
);
.
pipe
(
res
);
};
};
this
.
peers
=
function
(
req
,
res
)
{
res
.
type
(
'
application/json
'
);
co
(
function
*
()
{
try
{
let
peers
=
yield
server
.
dal
.
listAllPeers
();
var
json
=
{
peers
:
peers
.
map
((
p
)
=>
{
return
_
.
pick
(
p
,
'
version
'
,
'
currency
'
,
'
status
'
,
'
first_down
'
,
'
last_try
'
,
'
pubkey
'
,
'
block
'
,
'
signature
'
,
'
endpoints
'
);
})
};
res
.
send
(
200
,
JSON
.
stringify
(
json
,
null
,
"
"
));
}
catch
(
err
)
{
res
.
send
(
400
,
err
);
}
});
};
}
}
This diff is collapsed.
Click to expand it.
app/lib/streams/bma.js
+
1
−
0
View file @
102df6b9
...
@@ -83,6 +83,7 @@ module.exports = function(server, interfaces, httpLogs) {
...
@@ -83,6 +83,7 @@ module.exports = function(server, interfaces, httpLogs) {
answerForGet
(
'
/network/peering
'
,
net
.
peer
);
answerForGet
(
'
/network/peering
'
,
net
.
peer
);
answerForGet
(
'
/network/peering/peers
'
,
net
.
peersGet
);
answerForGet
(
'
/network/peering/peers
'
,
net
.
peersGet
);
answerForPost
(
'
/network/peering/peers
'
,
net
.
peersPost
);
answerForPost
(
'
/network/peering/peers
'
,
net
.
peersPost
);
answerForGet
(
'
/network/peers
'
,
net
.
peers
);
var
wot
=
require
(
'
../../controllers/wot
'
)(
server
);
var
wot
=
require
(
'
../../controllers/wot
'
)(
server
);
answerForPost
(
'
/wot/add
'
,
wot
.
add
);
answerForPost
(
'
/wot/add
'
,
wot
.
add
);
...
...
This diff is collapsed.
Click to expand it.
doc/HTTP_API.md
+
48
−
0
View file @
102df6b9
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
*
[
tx
](
#blockchainwithtx
)
*
[
tx
](
#blockchainwithtx
)
*
[
branches
](
#blockchainbranches
)
*
[
branches
](
#blockchainbranches
)
*
[
network/
](
#network
)
*
[
network/
](
#network
)
*
[
peers
](
#networkpeers
)
*
[
peering
](
#networkpeering
)
*
[
peering
](
#networkpeering
)
*
[
peering/peers (GET)
](
#networkpeeringpeers-get
)
*
[
peering/peers (GET)
](
#networkpeeringpeers-get
)
*
[
peering/peers (POST)
](
#networkpeeringpeers-post
)
*
[
peering/peers (POST)
](
#networkpeeringpeers-post
)
...
@@ -80,6 +81,7 @@ Data is made accessible through an HTTP API mainly inspired from [OpenUDC_exchan
...
@@ -80,6 +81,7 @@ Data is made accessible through an HTTP API mainly inspired from [OpenUDC_exchan
| | `-- [NUMBER]
| | `-- [NUMBER]
| `-- current
| `-- current
|-- network/
|-- network/
| |-- peers
| `-- peering
| `-- peering
| `-- peers
| `-- peers
|-- tx/
|-- tx/
...
@@ -1003,6 +1005,52 @@ Top block of each branch, i.e. the last received block of each branch. An array
...
@@ -1003,6 +1005,52 @@ Top block of each branch, i.e. the last received block of each branch. An array
This URL is used for uCoin Gossip protocol (exchanging UCG messages).
This URL is used for uCoin Gossip protocol (exchanging UCG messages).
#### `network/peers`
**Goal**
GET the exhaustive list of peers known by the node.
**Parameters**
*None*
.
**Returns**
List of peering entries.
```
json
{
"peers"
:
[
{
"version"
:
"1"
,
"currency"
:
"meta_brouzouf"
,
"status"
:
"UP"
,
"first_down"
:
null
,
"last_try"
:
null
,
"pubkey"
:
"HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
,
"block"
:
"45180-00000E577DD4B308B98D0ED3E43926CE4D22E9A8"
,
"signature"
:
"GKTrlUc4um9lQuj9UI8fyA/n/JKieYqBYcl9keIWfAVOnvHamLHaqGzijsdX1kNt64cadcle/zkd7xOgMTdQAQ=="
,
"endpoints"
:
[
"BASIC_MERKLED_API metab.ucoin.io 88.174.120.187 9201"
]
},
{
"version"
:
"1"
,
"currency"
:
"meta_brouzouf"
,
"status"
:
"UP"
,
"first_down"
:
null
,
"last_try"
:
null
,
"pubkey"
:
"2aeLmae5d466y8D42wLK5MknwUBCR6MWWeixRzdTQ4Hu"
,
"block"
:
"45182-0000064EEF412C1CDD1B370CC45A3BC3B9743464"
,
"signature"
:
"kbdTay1OirDqG/E3jyCaDlL7HVVHb9/BXvNHAg+xO9sSA+NgmBo/4mEqL9b7hH0UnbXHss6TfuvxAHZLmBqsCw=="
,
"endpoints"
:
[
"BASIC_MERKLED_API twiced.fr 88.174.120.187 9223"
]
},
...
]
}
```
#### `network/peering`
#### `network/peering`
**Goal**
**Goal**
...
...
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