Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ginkgo
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
vjrj
ginkgo
Commits
778a28cf
Commit
778a28cf
authored
10 months ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
Contact c+ and wot merge. getProfile with full resize. Disable polkadart for web (temporally)
parent
ef40173e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/g1/api.dart
+33
-24
33 additions, 24 deletions
lib/g1/api.dart
with
33 additions
and
24 deletions
lib/g1/api.dart
+
33
−
24
View file @
778a28cf
...
@@ -77,7 +77,7 @@ Future<Response> searchCPlusUser(String initialSearchTerm) async {
...
@@ -77,7 +77,7 @@ Future<Response> searchCPlusUser(String initialSearchTerm) async {
}
}
Future
<
Contact
>
getProfile
(
String
pubKeyRaw
,
Future
<
Contact
>
getProfile
(
String
pubKeyRaw
,
[
bool
onlyCPlusProfile
=
false
]
)
async
{
{
bool
onlyCPlusProfile
=
false
,
bool
resize
=
true
}
)
async
{
final
String
pubKey
=
extractPublicKey
(
pubKeyRaw
);
final
String
pubKey
=
extractPublicKey
(
pubKeyRaw
);
try
{
try
{
final
Response
cPlusResponse
=
(
await
requestCPlusWithRetry
(
final
Response
cPlusResponse
=
(
await
requestCPlusWithRetry
(
...
@@ -86,19 +86,22 @@ Future<Contact> getProfile(String pubKeyRaw,
...
@@ -86,19 +86,22 @@ Future<Contact> getProfile(String pubKeyRaw,
.
item2
;
.
item2
;
final
Map
<
String
,
dynamic
>
result
=
final
Map
<
String
,
dynamic
>
result
=
const
JsonDecoder
()
.
convert
(
cPlusResponse
.
body
)
as
Map
<
String
,
dynamic
>;
const
JsonDecoder
()
.
convert
(
cPlusResponse
.
body
)
as
Map
<
String
,
dynamic
>;
Contact
c
;
if
(
result
[
'found'
]
==
false
)
{
if
(
result
[
'found'
]
==
false
)
{
return
Contact
(
pubKey:
pubKey
);
c
=
Contact
(
pubKey:
pubKey
);
}
else
{
final
Map
<
String
,
dynamic
>
profile
=
const
JsonDecoder
()
.
convert
(
cPlusResponse
.
body
)
as
Map
<
String
,
dynamic
>;
c
=
await
contactFromResultSearch
(
profile
,
resize:
resize
);
}
}
final
Map
<
String
,
dynamic
>
profile
=
const
JsonDecoder
()
.
convert
(
cPlusResponse
.
body
)
as
Map
<
String
,
dynamic
>;
final
Contact
c
=
await
contactFromResultSearch
(
profile
);
if
(
!
onlyCPlusProfile
)
{
if
(
!
onlyCPlusProfile
)
{
// This penalize the gva rate limit
// This penalize the gva rate limit
// final String? nick = await gvaNick(pubKey);
// final String? nick = await gvaNick(pubKey);
final
List
<
Contact
>
wotList
=
await
searchWotV
2
(
pubKey
);
final
List
<
Contact
>
wotList
=
await
searchWotV
1
(
pubKey
);
if
(
wotList
.
isNotEmpty
)
{
if
(
wotList
.
isNotEmpty
)
{
final
Contact
c
=
wotList
[
0
];
final
Contact
cWot
=
wotList
[
0
];
c
.
copyWith
(
nick:
c
.
nick
);
c
=
c
.
merge
(
cWot
);
// c.copyWith(nick: c.nick);
}
}
}
}
logger
(
'Contact retrieved in getProfile
$c
(c+ only
$onlyCPlusProfile
)'
);
logger
(
'Contact retrieved in getProfile
$c
(c+ only
$onlyCPlusProfile
)'
);
...
@@ -513,21 +516,27 @@ Future<NodeCheck> _pingNode(String node, NodeType type) async {
...
@@ -513,21 +516,27 @@ Future<NodeCheck> _pingNode(String node, NodeType type) async {
stopwatch.stop();
stopwatch.stop();
latency = stopwatch.elapsed;
latency = stopwatch.elapsed;
} else if (type == NodeType.endpoint) {
} else if (type == NodeType.endpoint) {
try {
if (!kIsWeb) {
final Provider polkadot = Provider(Uri.parse(node));
try {
// From:
final Provider polkadot = Provider(Uri.parse(node));
// https://github.com/leonardocustodio/polkadart/blob/main/examples/bin/extrinsic_demo.dart
// From:
final RpcResponse<dynamic> block =
// https://github.com/leonardocustodio/polkadart/blob/main/examples/bin/extrinsic_demo.dart
await polkadot.send('
chain_getBlock
', <dynamic>[]);
final RpcResponse<dynamic> block =
currentBlock = int.parse(
await polkadot.send('
chain_getBlock
', <dynamic>[]);
(((block.result as Map<String, dynamic>)['
block
']
currentBlock = int.parse(
as Map<String, dynamic>)['
header
']
(((block.result as Map<String, dynamic>)['
block
']
as Map<String, dynamic>)['
number
'] as String);
as Map<String, dynamic>)['
header
']
stopwatch.stop();
as Map<String, dynamic>)['
number
'] as String);
latency = stopwatch.elapsed;
stopwatch.stop();
await polkadot.disconnect();
latency = stopwatch.elapsed;
} catch (e) {
await polkadot.disconnect();
loggerDev('
Cannot
parse
node
/
stats
$e
');
} catch (e) {
loggerDev('
Cannot
parse
node
/
stats
$e
');
latency = wrongNodeDuration;
}
} else {
// Waiting for web support in polkadart:
// https://github.com/leonardocustodio/polkadart/issues/297
latency = wrongNodeDuration;
latency = wrongNodeDuration;
}
}
} else if (type == NodeType.duniterIndexer) {
} else if (type == NodeType.duniterIndexer) {
...
@@ -939,7 +948,7 @@ void hashAndSign(Map<String, dynamic> data, CesiumWallet wallet) {
...
@@ -939,7 +948,7 @@ void hashAndSign(Map<String, dynamic> data, CesiumWallet wallet) {
}
}
Future
<
String
?
>
getCesiumPlusUser
(
String
pubKey
)
async
{
Future
<
String
?
>
getCesiumPlusUser
(
String
pubKey
)
async
{
final
Contact
c
=
await
getProfile
(
pubKey
,
true
);
final
Contact
c
=
await
getProfile
(
pubKey
,
onlyCPlusProfile:
true
);
return
c
.
name
;
return
c
.
name
;
}
}
...
...
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