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
d0b9e47d
Commit
d0b9e47d
authored
2 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
feature: enhance `import-lookup` command to forward memberships
parent
b72f63d0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/modules/bma/lib/dtos.ts
+5
-0
5 additions, 0 deletions
app/modules/bma/lib/dtos.ts
app/modules/crawler/index.ts
+49
-9
49 additions, 9 deletions
app/modules/crawler/index.ts
with
54 additions
and
9 deletions
app/modules/bma/lib/dtos.ts
+
5
−
0
View file @
d0b9e47d
...
...
@@ -629,6 +629,11 @@ export const RequirementsPendingMembership = {
type
:
String
,
blockstamp
:
String
,
sig
:
String
,
signature
:
String
,
issuer
:
String
,
membership
:
String
,
userid
:
String
,
certts
:
String
,
};
export
interface
HttpRequirementsPendingMembership
{
...
...
This diff is collapsed.
Click to expand it.
app/modules/crawler/index.ts
+
49
−
9
View file @
d0b9e47d
...
...
@@ -561,7 +561,8 @@ export const CrawlerDependency = {
},
},
{
name
:
"
import-lookup [search] [fromhost] [fromport] [tohost] [toport]
"
,
name
:
"
import-lookup [search] [fromhost] [fromport] [frompath] [tohost] [toport] [topath]
"
,
desc
:
"
Exchange peerings with another node
"
,
onDatabaseExecute
:
async
(
server
:
Server
,
...
...
@@ -572,18 +573,31 @@ export const CrawlerDependency = {
const
search
=
params
[
0
];
const
fromhost
=
params
[
1
];
const
fromport
=
params
[
2
];
const
tohost
=
params
[
3
];
const
toport
=
params
[
4
];
const
frompath
=
params
[
3
];
const
tohost
=
params
[
4
];
const
toport
=
params
[
5
];
const
topath
=
params
[
6
];
const
logger
=
server
.
logger
;
try
{
logger
.
info
(
'
Looking for "%s" at %s:%s...
'
,
'
Looking for "%s" at %s:%s
%s
...
'
,
search
,
fromhost
,
fromport
fromport
,
frompath
);
const
sourcePeer
=
Contacter
.
fromHostPortPath
(
fromhost
,
fromport
,
frompath
,
{
timeout
:
60
*
1000
}
);
const
targetPeer
=
Contacter
.
fromHostPortPath
(
tohost
,
toport
,
topath
,
{
timeout
:
60
*
1000
}
);
const
sourcePeer
=
new
Contacter
(
fromhost
,
fromport
);
const
targetPeer
=
new
Contacter
(
tohost
,
toport
);
const
lookup
=
await
sourcePeer
.
getLookup
(
search
);
for
(
const
res
of
lookup
.
results
)
{
for
(
const
uid
of
res
.
uids
)
{
...
...
@@ -627,7 +641,12 @@ export const CrawlerDependency = {
}
}
}
const
certBy
=
await
sourcePeer
.
getCertifiedBy
(
search
);
let
certBy
:
any
=
{
certifications
:
[]
};
try
{
certBy
=
await
sourcePeer
.
getCertifiedBy
(
search
);
}
catch
(
e
)
{
logger
.
error
(
"
No certified-by on remote
"
);
}
const
mapBlocks
:
any
=
{};
for
(
const
signed
of
certBy
.
certifications
)
{
if
(
signed
.
written
)
{
...
...
@@ -667,7 +686,7 @@ export const CrawlerDependency = {
});
try
{
logger
.
info
(
"
Success
cert %s -> %s
"
,
"
Posting
cert %s -> %s
"
,
certBy
.
pubkey
.
slice
(
0
,
8
),
signed
.
uid
);
...
...
@@ -677,6 +696,27 @@ export const CrawlerDependency = {
}
}
}
// Memberships
const
requirements
=
await
sourcePeer
.
getRequirements
(
search
);
for
(
let
idty
of
requirements
.
identities
)
{
for
(
let
pendingMs
of
idty
.
pendingMemberships
)
{
const
rawMs
=
rawer
.
getMembership
({
currency
:
"
g1
"
,
issuer
:
pendingMs
.
issuer
,
type
:
pendingMs
.
membership
,
blockstamp
:
pendingMs
.
blockstamp
,
userid
:
pendingMs
.
userid
,
certts
:
pendingMs
.
certts
,
signature
:
pendingMs
.
signature
,
});
try
{
logger
.
info
(
"
Posting membership
"
);
await
targetPeer
.
postRenew
(
rawMs
);
}
catch
(
e
)
{
logger
.
error
(
e
);
}
}
}
logger
.
info
(
"
Sent.
"
);
await
server
.
disconnect
();
}
catch
(
e
)
{
...
...
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