22// is contributing to the network. The Exporters will then take this data and publish
33// it to the networks.
44use {
5- super :: {
6- PriceIdentifier ,
7- State ,
8- } ,
5+ super :: State ,
96 crate :: agent:: metrics:: PriceLocalMetrics ,
107 anyhow:: {
118 anyhow,
@@ -45,7 +42,7 @@ impl PriceInfo {
4542}
4643
4744pub struct Store {
48- prices : RwLock < HashMap < PriceIdentifier , PriceInfo > > ,
45+ prices : RwLock < HashMap < pyth_sdk :: Identifier , PriceInfo > > ,
4946 metrics : PriceLocalMetrics ,
5047 logger : Logger ,
5148}
@@ -62,8 +59,12 @@ impl Store {
6259
6360#[ async_trait:: async_trait]
6461pub trait LocalStore {
65- async fn update ( & self , price_identifier : PriceIdentifier , price_info : PriceInfo ) -> Result < ( ) > ;
66- async fn get_all_price_infos ( & self ) -> HashMap < PriceIdentifier , PriceInfo > ;
62+ async fn update (
63+ & self ,
64+ price_identifier : pyth_sdk:: Identifier ,
65+ price_info : PriceInfo ,
66+ ) -> Result < ( ) > ;
67+ async fn get_all_price_infos ( & self ) -> HashMap < pyth_sdk:: Identifier , PriceInfo > ;
6768}
6869
6970// Allow downcasting State into GlobalStore for functions that depend on the `GlobalStore` service.
7980 for < ' a > & ' a T : Into < & ' a Store > ,
8081 T : Sync ,
8182{
82- async fn update ( & self , price_identifier : PriceIdentifier , price_info : PriceInfo ) -> Result < ( ) > {
83+ async fn update (
84+ & self ,
85+ price_identifier : pyth_sdk:: Identifier ,
86+ price_info : PriceInfo ,
87+ ) -> Result < ( ) > {
8388 debug ! ( self . into( ) . logger, "local store received price update" ; "identifier" => bs58:: encode( price_identifier. to_bytes( ) ) . into_string( ) ) ;
8489
8590 // Drop the update if it is older than the current one stored for the price
@@ -102,7 +107,7 @@ where
102107 Ok ( ( ) )
103108 }
104109
105- async fn get_all_price_infos ( & self ) -> HashMap < PriceIdentifier , PriceInfo > {
110+ async fn get_all_price_infos ( & self ) -> HashMap < pyth_sdk :: Identifier , PriceInfo > {
106111 self . into ( ) . prices . read ( ) . await . clone ( )
107112 }
108113}
0 commit comments