1212/// from the publisher to the router.
1313#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
1414#[ serde( rename_all = "camelCase" ) ]
15- pub struct PriceFeedData {
15+ pub struct PriceFeedDataV2 {
1616 pub price_feed_id : PriceFeedId ,
1717 /// Timestamp of the last update provided by the source of the prices
1818 /// (like an exchange). If unavailable, this value is set to `publisher_timestamp_us`.
@@ -41,7 +41,7 @@ pub struct PriceFeedData {
4141/// Superseded by `PriceFeedData`.
4242#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
4343#[ serde( rename_all = "camelCase" ) ]
44- pub struct PriceFeedDataV0 {
44+ pub struct PriceFeedDataV1 {
4545 pub price_feed_id : PriceFeedId ,
4646 /// Timestamp of the last update provided by the source of the prices
4747 /// (like an exchange). If unavailable, this value is set to `publisher_timestamp_us`.
@@ -62,8 +62,8 @@ pub struct PriceFeedDataV0 {
6262 pub best_ask_price : Option < Price > ,
6363}
6464
65- impl From < PriceFeedDataV0 > for PriceFeedData {
66- fn from ( v0 : PriceFeedDataV0 ) -> Self {
65+ impl From < PriceFeedDataV1 > for PriceFeedDataV2 {
66+ fn from ( v0 : PriceFeedDataV1 ) -> Self {
6767 Self {
6868 price_feed_id : v0. price_feed_id ,
6969 source_timestamp_us : v0. source_timestamp_us ,
@@ -103,7 +103,7 @@ fn price_feed_data_serde() {
103103 1 , 7 , 3 , 0 , 0 , 0 , 0 , 0 , 0 , // funding_rate
104104 ] ;
105105
106- let expected = PriceFeedData {
106+ let expected = PriceFeedDataV2 {
107107 price_feed_id : PriceFeedId ( 1 ) ,
108108 source_timestamp_us : TimestampUs ( 2 ) ,
109109 publisher_timestamp_us : TimestampUs ( 3 ) ,
@@ -113,7 +113,7 @@ fn price_feed_data_serde() {
113113 funding_rate : Some ( 3 * 256 + 7 ) ,
114114 } ;
115115 assert_eq ! (
116- bincode:: deserialize:: <PriceFeedData >( & data) . unwrap( ) ,
116+ bincode:: deserialize:: <PriceFeedDataV2 >( & data) . unwrap( ) ,
117117 expected
118118 ) ;
119119 assert_eq ! ( bincode:: serialize( & expected) . unwrap( ) , data) ;
@@ -127,7 +127,7 @@ fn price_feed_data_serde() {
127127 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // best_ask_price
128128 0 , // funding_rate
129129 ] ;
130- let expected2 = PriceFeedData {
130+ let expected2 = PriceFeedDataV2 {
131131 price_feed_id : PriceFeedId ( 1 ) ,
132132 source_timestamp_us : TimestampUs ( 2 ) ,
133133 publisher_timestamp_us : TimestampUs ( 3 ) ,
@@ -137,7 +137,7 @@ fn price_feed_data_serde() {
137137 funding_rate : None ,
138138 } ;
139139 assert_eq ! (
140- bincode:: deserialize:: <PriceFeedData >( & data2) . unwrap( ) ,
140+ bincode:: deserialize:: <PriceFeedDataV2 >( & data2) . unwrap( ) ,
141141 expected2
142142 ) ;
143143 assert_eq ! ( bincode:: serialize( & expected2) . unwrap( ) , data2) ;
0 commit comments