At
view release on metacpan or search on metacpan
Retrieves a raw block by its CID. If an `ipfs_node` was provided to the constructor, this method will:
- Check the local blockstore.
- Attempt to fetch the block via Bitswap from the provided `$target_peer_id`.
- Fall back to the centralized PDS via HTTP if the block is not found in the P2P network.
Returns a [Future](https://metacpan.org/pod/Future) that resolves to the block data.
# Decentralized Data Synchronization
When an `ipfs_node` is provided to the [At](https://metacpan.org/pod/At) constructor, the library enables peer-to-peer data synchronization
compliant with the AT Protocol Sync specification ([https://atproto.com/specs/sync](https://atproto.com/specs/sync)).
## Peer-to-Peer Repository Mirroring
By combining `peer_id_for_did` and `get_block`, this library can mirror entire user repositories without relying on a
centralized Relay or PDS. The process involves:
- Identity bridging: Converting the user's DID to a libp2p PeerID.
- Root resolution: Getting the latest MST root CID.
- MST traversal: Recursively walking the Merkle Search Tree.
eg/p2p_sync.pl view on Meta::CPAN
say "Bridging DID $did to libp2p...";
my $peer_id = $at->peer_id_for_did($did);
say 'Successfully resolved to PeerID: ' . $peer_id->to_string() if $peer_id;
# Fetch a repository block
# In a real scenario, you would first get the root CID via $at->get_repo_head($did)
my $root_cid_str = 'bafyreia2izlj2wnxrwzoh4skwlahyc2conqdjugbsvy6eu5qtyc7ws6dsu';
say "Fetching repository block $root_cid_str via P2P...";
my $f = $at->get_block( $root_cid_str, $peer_id ? $peer_id->to_string : undef );
# Since this is an asynchronous operation, we drive the loop until the block arrives
# or the request fails.
while ( !$f->is_ready ) {
$node->host->io_utils->loop->loop_once(0.1);
}
if ( $f->is_done ) {
my $data = $f->get;
say 'Successfully retrieved ' . length($data) . ' bytes from the P2P network!';
}
else {
say 'P2P retrieval failed: ' . $f->failure;
=item Attempt to fetch the block via Bitswap from the provided C<$target_peer_id>.
=item Fall back to the centralized PDS via HTTP if the block is not found in the P2P network.
=back
Returns a L<Future> that resolves to the block data.
=head1 Decentralized Data Synchronization
When an C<ipfs_node> is provided to the L<At> constructor, the library enables peer-to-peer data synchronization
compliant with the AT Protocol Sync specification (L<https://atproto.com/specs/sync>).
=head2 Peer-to-Peer Repository Mirroring
By combining C<peer_id_for_did> and C<get_block>, this library can mirror entire user repositories without relying on a
centralized Relay or PDS. The process involves:
=over
=item Identity bridging: Converting the user's DID to a libp2p PeerID.
lib/At/UserAgent.pm view on Meta::CPAN
C<At::UserAgent> defines the interface for HTTP clients used by L<At>. It handles DPoP proof generation, automatic
nonce management, and authentication headers.
=head1 Subclasses
=over
=item L<At::UserAgent::Mojo>
Uses L<Mojo::UserAgent>. Recommended for asynchronous or high-performance applications.
=item L<At::UserAgent::Tiny>
Uses L<HTTP::Tiny>. A lightweight, zero-dependency alternative. Does not support firehose/WebSockets.
=back
=head1 Attributes
=head2 C<accessJwt()>
share/lexicons/app/bsky/actor/getPreferences.json view on Meta::CPAN
{
"lexicon": 1,
"id": "app.bsky.actor.getPreferences",
"defs": {
"main": {
"type": "query",
"description": "Get private preferences attached to the current account. Expected use is synchronization between multiple devices, and import/export during account migration. Requires auth.",
"parameters": {
"type": "params",
"properties": {}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["preferences"],
"properties": {
share/lexicons/com/atproto/sync/getRepoStatus.json view on Meta::CPAN
"did": { "type": "string", "format": "did" },
"active": { "type": "boolean" },
"status": {
"type": "string",
"description": "If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted...
"knownValues": [
"takendown",
"suspended",
"deleted",
"deactivated",
"desynchronized",
"throttled"
]
},
"rev": {
"type": "string",
"format": "tid",
"description": "Optional field, the current rev of the repo, if active=true"
}
}
}
share/lexicons/com/atproto/sync/listRepos.json view on Meta::CPAN
"rev": { "type": "string", "format": "tid" },
"active": { "type": "boolean" },
"status": {
"type": "string",
"description": "If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.",
"knownValues": [
"takendown",
"suspended",
"deleted",
"deactivated",
"desynchronized",
"throttled"
]
}
}
}
}
}
share/lexicons/com/atproto/sync/subscribeRepos.json view on Meta::CPAN
"description": "Indicates that the account has a repository which can be fetched from the host that emitted this event."
},
"status": {
"type": "string",
"description": "If active=false, this optional field indicates a reason for why the account is not active.",
"knownValues": [
"takendown",
"suspended",
"deleted",
"deactivated",
"desynchronized",
"throttled"
]
}
}
},
"info": {
"type": "object",
"required": ["name"],
"properties": {
"name": {
( run in 2.842 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )