Skip to content

Commit 2989172

Browse files
committed
used bitswap compute cid function
1 parent 97ee19b commit 2989172

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

examples/bitswap/bitswap.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import trio
2222

2323
from libp2p import new_host
24-
from libp2p.bitswap import BitswapClient, MemoryBlockStore
24+
from libp2p.bitswap import BitswapClient, MemoryBlockStore, compute_cid
2525
from libp2p.peer.peerinfo import info_from_p2p_addr
2626

2727
# Enable logging
@@ -37,17 +37,6 @@
3737
logger = logging.getLogger("bitswap_example")
3838

3939

40-
def compute_cid(data: bytes) -> bytes:
41-
"""
42-
Compute a simple CID for data.
43-
44-
Note: This is a simplified CID computation for demonstration.
45-
In a real implementation, you should use proper CIDv0/CIDv1 encoding
46-
with multihash and multicodec.
47-
"""
48-
return hashlib.sha256(data).digest()
49-
50-
5140
async def run_provider(port: int = 0, file_path: str | None = None) -> None:
5241
"""
5342
Run a Bitswap provider node that serves blocks.

0 commit comments

Comments
 (0)