Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way of importing CAR files (for backfilling) #8

Closed
alnkesq opened this issue Jan 11, 2025 · 2 comments
Closed

Add a way of importing CAR files (for backfilling) #8

alnkesq opened this issue Jan 11, 2025 · 2 comments

Comments

@alnkesq
Copy link
Owner

alnkesq commented Jan 11, 2025

I already have some draft code, but it compiles against an old version of FishyFlip, and migrating would require a replacement for ATRecord.FromCBORObject (which no longer exists or isn't public)

@drasticactions
Copy link
Contributor

I don't believe you should need that.

https://github.com/drasticactions/FishyFlip/blob/develop/src/FishyFlip/Tools/CarDecoder.cs#L26

CarDecoder.DecodeCar takes in a CAR and decodes it into record files which get exposed via OnCarDecoded as events. That would get you the ATObject's that exist within a CAR file.

You could also do what the Firehose code does (https://github.com/drasticactions/FishyFlip/blob/develop/src/FishyFlip/ATWebSocketProtocol.cs#L200-L259)

using var blockStream = new MemoryStream(e.Bytes);
var blockObj = CBORObject.Read(blockStream);
if (blockObj["$type"] is not null)
{
    message.Record = blockObj.ToATObject();
    this.OnRecordReceived?.Invoke(this, new RecordMessageReceivedEventArgs(frameCommit, message.Record));
}

You can create a CBORObject with CBORObject.Read and use .ToATObject(); to turn it into an ATObject.

If you need something else, feel free to file a bug.

@alnkesq
Copy link
Owner Author

alnkesq commented Jan 12, 2025

You're right, ToATObject is what I was looking for.
163b7ca

@alnkesq alnkesq closed this as completed Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants