@@ -11,8 +11,8 @@ use crate::{
1111 hello:: { HelloCodec , HelloProtocolName } ,
1212} ;
1313use cid:: Cid ;
14+ use forest_db:: CidCompatBitswap ;
1415use forest_encoding:: blake2b_256;
15- use libipld:: store:: StoreParams ;
1616use libp2p:: swarm:: NetworkBehaviour ;
1717use libp2p:: { core:: identity:: Keypair , kad:: QueryId } ;
1818use libp2p:: { core:: PeerId , gossipsub:: GossipsubMessage } ;
@@ -28,6 +28,7 @@ use libp2p::{
2828 metrics:: { Metrics , Recorder } ,
2929 request_response:: { ProtocolSupport , RequestResponse , RequestResponseConfig } ,
3030} ;
31+ use libp2p_bitswap:: libipld:: store:: StoreParams ;
3132use libp2p_bitswap:: { Bitswap , BitswapConfig , BitswapStore } ;
3233use log:: { debug, warn} ;
3334use std:: collections:: { HashMap , HashSet } ;
@@ -88,7 +89,13 @@ impl<P: StoreParams> ForestBehaviour<P> {
8889 )
8990 . unwrap ( ) ;
9091
91- let bitswap = Bitswap :: new ( BitswapConfig :: new ( ) , db) ;
92+ let bitswap = Bitswap :: new (
93+ BitswapConfig {
94+ compat_protocol_name : b"/chain/ipfs/bitswap/1.2.0" ,
95+ ..Default :: default ( )
96+ } ,
97+ db,
98+ ) ;
9299 if let Err ( err) = bitswap. register_metrics ( prometheus:: default_registry ( ) ) {
93100 warn ! ( "Fail to register prometheus metrics for libp2p_bitswap: {err}" ) ;
94101 }
@@ -155,7 +162,9 @@ impl<P: StoreParams> ForestBehaviour<P> {
155162 pub fn want_block ( & mut self , cid : Cid ) -> anyhow:: Result < libp2p_bitswap:: QueryId > {
156163 debug ! ( "want {}" , cid. to_string( ) ) ;
157164 let peers = self . discovery . peers ( ) . iter ( ) . cloned ( ) . collect ( ) ;
158- let query_id = self . bitswap . sync ( cid, peers, [ cid] . into_iter ( ) ) ;
165+ let query_id = self
166+ . bitswap
167+ . sync ( cid. compat ( ) , peers, [ cid. compat ( ) ] . into_iter ( ) ) ;
159168 Ok ( query_id)
160169 }
161170}
0 commit comments