11use anyhow:: Result ;
22use chrono:: { DateTime , Utc } ;
3- use offer:: GolemBaseOffer ;
43use std:: collections:: HashSet ;
54use std:: env;
65use std:: sync:: { Arc , Mutex } ;
76use std:: time:: Duration ;
87use tokio:: task:: JoinHandle ;
9- use ya_service_bus:: timeout:: IntoTimeoutFuture ;
108
119use ya_client:: model:: NodeId ;
1210use ya_core_model:: bus:: GsbBindPoints ;
13- use ya_core_model:: identity:: event:: IdentityEvent ;
14- use ya_core_model:: identity:: Error ;
15- use ya_core_model:: market:: { local, GetGolemBaseOffer , GetGolemBaseOfferResponse } ;
16- use ya_core_model:: market:: {
17- FundGolemBase , GetGolemBaseBalance , GolemBaseCommand , RpcMessageError ,
18- } ;
19- use ya_service_bus:: typed as bus;
2011
2112use super :: callback:: HandlerSlot ;
2213use crate :: config:: DiscoveryConfig ;
23- use crate :: db:: model:: { Offer as ModelOffer , SubscriptionId } ;
24- use crate :: identity:: { IdentityApi , IdentityError , YagnaIdSigner } ;
14+ use crate :: db:: model:: Offer as ModelOffer ;
15+ use crate :: identity:: IdentityApi ;
2516use crate :: protocol:: discovery:: error:: * ;
2617use crate :: protocol:: discovery:: message:: * ;
27- use arkiv_sdk:: client:: ArkivClient ;
28- use arkiv_sdk:: entity:: Create ;
29- use arkiv_sdk:: events:: Event ;
30- use arkiv_sdk:: rpc:: { QueryOptions , SearchResult } ;
31- use arkiv_sdk:: signers:: TransactionSigner ;
32- use arkiv_sdk:: { Address , Hash } ;
33- use rand:: { thread_rng, Rng } ;
3418
3519const ARKIV_CALLER : & str = "Arkiv" ;
3620
37- // TODO: Get this value from node configuration
38- const BLOCK_TIME_SECONDS : i64 = 2 ;
39-
4021pub mod builder;
4122pub mod error;
4223pub mod faucet;
@@ -61,24 +42,11 @@ pub struct DiscoveryImpl {
6142 //arkiv: ArkivClient,
6243 offer_handlers : OfferHandlers ,
6344 config : DiscoveryConfig ,
64- identities : Mutex < HashSet < NodeId > > ,
45+ _identities : Mutex < HashSet < NodeId > > ,
6546 websocket_task : Mutex < Option < JoinHandle < ( ) > > > ,
6647}
6748
6849impl Discovery {
69-
70- /// Checks if an offer belongs to us based on metadata and entity_id
71- fn _is_own_offer ( & self , metadata : & SearchResult ) -> bool {
72- let Some ( owner) = metadata. owner . as_ref ( ) else {
73- log:: warn!( "[Programming error] Entity metadata should contain owner!" ) ;
74- return false ;
75- } ;
76-
77- let identities = self . inner . identities . lock ( ) . unwrap ( ) ;
78- let owner_bytes = NodeId :: from ( owner. as_slice ( ) ) ;
79- identities. contains ( & owner_bytes)
80- }
81-
8250 async fn offers_events_loop ( & self , _starting_block : u64 ) -> anyhow:: Result < ( ) > {
8351 let default_identity = self
8452 . inner
@@ -246,10 +214,9 @@ impl Discovery {
246214 Ok ( ( ) )
247215 }
248216
249-
250217 /// Function doesn't bind any GSB handlers.
251218 /// It's only used to sync with GolemBase node and initialize Discovery struct state.
252- pub async fn bind_gsb ( & self , gsb : GsbBindPoints ) -> Result < ( ) , DiscoveryInitError > {
219+ pub async fn bind_gsb ( & self , _gsb : GsbBindPoints ) -> Result < ( ) , DiscoveryInitError > {
253220 log:: info!( "Arkiv Configuration:" ) ;
254221 log:: info!( " Network: {:?}" , self . inner. config. get_network_type( ) ) ;
255222 log:: info!( " RPC URL: {}" , self . inner. config. get_rpc_url( ) ) ;
@@ -295,10 +262,6 @@ impl Discovery {
295262 Ok ( ( ) )
296263 }
297264
298-
299-
300-
301-
302265 pub ( crate ) async fn get_last_bcast_ts ( & self ) -> DateTime < Utc > {
303266 Utc :: now ( )
304267 }
0 commit comments