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
3c48177e
Commit
3c48177e
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[ref] gva: fusion sub newBlockMeta with newBlock
parent
339cf597
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
rust-libs/modules/gva/gql/src/subscriptions/new_blocks.rs
+59
-48
59 additions, 48 deletions
rust-libs/modules/gva/gql/src/subscriptions/new_blocks.rs
with
59 additions
and
48 deletions
rust-libs/modules/gva/gql/src/subscriptions/new_blocks.rs
+
59
−
48
View file @
3c48177e
...
@@ -16,43 +16,52 @@
...
@@ -16,43 +16,52 @@
use
super
::
create_subscription
;
use
super
::
create_subscription
;
use
crate
::
*
;
use
crate
::
*
;
use
duniter_dbs
::
databases
::
cm_v1
::{
CmV1DbReadable
,
CurrentBlockEvent
,
CurrentBlockMetaEvent
};
use
duniter_dbs
::
databases
::
cm_v1
::{
CmV1DbReadable
,
CurrentBlockEvent
,
CurrentBlockMetaEvent
};
use
futures
::
future
::
Either
;
#[derive(Clone,
Copy,
Default)]
#[derive(Clone,
Copy,
Default)]
pub
struct
NewBlocksSubscription
;
pub
struct
NewBlocksSubscription
;
#[async_graphql::Subscription]
#[async_graphql::Subscription]
impl
NewBlocksSubscription
{
impl
NewBlocksSubscription
{
async
fn
new_blocks
_meta
(
async
fn
new_blocks
(
&
self
,
&
self
,
ctx
:
&
async_graphql
::
Context
<
'_
>
,
ctx
:
&
async_graphql
::
Context
<
'_
>
,
)
->
impl
Stream
<
Item
=
async_graphql
::
Result
<
Vec
<
BlockMeta
>>>
{
)
->
impl
Stream
<
Item
=
async_graphql
::
Result
<
Vec
<
Block
>>>
{
let
meta_only
=
!
(
ctx
.look_ahead
()
.field
(
"identities"
)
.exists
()
||
ctx
.look_ahead
()
.field
(
"joiners"
)
.exists
()
||
ctx
.look_ahead
()
.field
(
"actives"
)
.exists
()
||
ctx
.look_ahead
()
.field
(
"leavers"
)
.exists
()
||
ctx
.look_ahead
()
.field
(
"revoked"
)
.exists
()
||
ctx
.look_ahead
()
.field
(
"excluded"
)
.exists
()
||
ctx
.look_ahead
()
.field
(
"certifications"
)
.exists
()
||
ctx
.look_ahead
()
.field
(
"transactions"
)
.exists
());
if
meta_only
{
Either
::
Left
(
create_subscription
(
create_subscription
(
ctx
,
ctx
,
|
dbs
|
dbs
.cm_db
.current_block_meta
(),
|
dbs
|
dbs
.cm_db
.current_block_meta
(),
|
events
|
{
|
events
|
{
let
mut
blocks
_meta
=
Vec
::
new
();
let
mut
blocks
=
Vec
::
new
();
for
event
in
events
.deref
()
{
for
event
in
events
.deref
()
{
if
let
CurrentBlockMetaEvent
::
Upsert
{
if
let
CurrentBlockMetaEvent
::
Upsert
{
value
:
ref
block_meta
,
value
:
ref
block_meta
,
..
..
}
=
event
}
=
event
{
{
blocks
_meta
.push
(
Block
Meta
::
from
(
block_meta
));
blocks
.push
(
Block
::
from
(
block_meta
));
}
}
}
}
if
blocks
_meta
.is_empty
()
{
if
blocks
.is_empty
()
{
futures
::
future
::
ready
(
None
)
futures
::
future
::
ready
(
None
)
}
else
{
}
else
{
futures
::
future
::
ready
(
Some
(
Ok
(
blocks
_meta
)))
futures
::
future
::
ready
(
Some
(
Ok
(
blocks
)))
}
}
},
},
)
)
.await
.await
,
}
)
async
fn
new_blocks
(
}
else
{
&
self
,
Either
::
Right
(
ctx
:
&
async_graphql
::
Context
<
'_
>
,
)
->
impl
Stream
<
Item
=
async_graphql
::
Result
<
Vec
<
Block
>>>
{
create_subscription
(
create_subscription
(
ctx
,
ctx
,
|
dbs
|
dbs
.cm_db
.current_block
(),
|
dbs
|
dbs
.cm_db
.current_block
(),
...
@@ -73,6 +82,8 @@ impl NewBlocksSubscription {
...
@@ -73,6 +82,8 @@ impl NewBlocksSubscription {
}
}
},
},
)
)
.await
.await
,
)
}
}
}
}
}
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