Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

feat(records): implement logic using ar.io/sdk #2

Merged
merged 12 commits into from
Mar 22, 2024

Conversation

dtfiedler
Copy link
Collaborator

@dtfiedler dtfiedler commented Mar 22, 2024

Fetches all records, their contract ids and inserts them into an LMDB that persists over restarts. Not totally necessary - but as the testnet contract grows, holding everything in memory and starting from scratch is not ideal. There are some additional optimizations to be made, but robust enough for now to start working with the ar-io-node.

Startup:

info: Evaluating arns names {"timestamp":"2024-03-22T21:08:10.687Z"}
info: Retrieved apex records: {"count":1674,"timestamp":"2024-03-22T21:08:11.468Z"}
error: Failed to get records for contract {"contractTxId":"cs2huk7R9rgpdKkcbjBNY-IjrKIZjEjQknvDCdSJS1E","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:13.288Z"}
error: Failed to get records for contract {"contractTxId":"K9kw8KbUJwL6vaJsHCgZDpxCKNgKjMUe6mA5Ka_jJ2w","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:14.058Z"}
error: Failed to get records for contract {"contractTxId":"VTq8_1eZ0xDb-SbGMfs7co-4fWa_gtrljinl6yOqCAY","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:14.503Z"}
error: Failed to get records for contract {"contractTxId":"SEFuOtV40V8I3m0fun8b-Br_RPQP5Yrk1UDWdT3jRK8","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:14.624Z"}
error: Failed to get records for contract {"contractTxId":"_QR3ZHxT7kW38eN4N2h8Vl0s8WLphJuucHLf5CG44LE","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:14.836Z"}
error: Failed to get records for contract {"contractTxId":"2yHmORN-N12hM1B2f9-JPMpOfa59qhpsExFCzImrD30","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:14.991Z"}
error: Failed to get records for contract {"contractTxId":"g1MHJdSDfUv4-ctMjnHefIeFa5KVgRvYEKwE2hYkbio","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:15.186Z"}
error: Failed to get records for contract {"contractTxId":"EdDYokA2LWduK1tHJWJ-R2T4G57IlCZ-WzOp1rCuS28","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:15.621Z"}
error: Failed to get records for contract {"contractTxId":"Y2g7Q354vGVtzKDu_hqVQg19ENsbT66l3PxUn15etJc","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:17.308Z"}
error: Failed to get records for contract {"contractTxId":"KIV8_fllrtnxNo9Jb50xuqyTxk0SHIT_9Zy3vVB_lyI","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:17.624Z"}
error: Failed to get records for contract {"contractTxId":"Eth-KNNG4YXvO8cgS5qHtPSRj3FqktGNJcs0nTnubdk","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:18.305Z"}
error: Failed to get records for contract {"contractTxId":"ozaC3NuGi8NBUPjNmxfq9Vvg0FmTZr4QbXO2N_Ulm7s","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:19.137Z"}
error: Failed to get records for contract {"contractTxId":"A99XKbHFwohTiPNKfV-hJHe06-nNiC4quneKwwYrGeE","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:21.850Z"}
error: Failed to get records for contract {"contractTxId":"lxNZkV--6EmWe0Ix_m6MnIRpICguuY-JWinKbWmw3Xw","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:21.856Z"}
error: Failed to get records for contract {"contractTxId":"yQmB6AC-r-R-sJByeTme2o_kaZqXc_lf_geTCMTfh8I","error":{"name":"NotFound"},"timestamp":"2024-03-22T21:08:21.863Z"}
info: Retrieved contract tx ids assigned to records: {"contractCount":1532,"timestamp":"2024-03-22T21:08:22.770Z"}
info: Successfully evaluated arns names {"durationMs":12124,"timestamp":"2024-03-22T21:08:22.811Z"}

APIs

❯ curl -iLs localhost:5001/ar-io/resolver/records/ardrive
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Cache-Control: public, max-age=3600
Content-Type: application/json; charset=utf-8
X-ArNS-Resolved-Id: nOXJjj_vk0Dc1yCgdWD8kti_1iHruGzLQLNNBHVpN0Y
X-ArNS-Ttl-Seconds: 2024-03-22T21:18:51.932Z
Content-Length: 245
ETag: W/"f5-GJBOp/zPdlhdTjbhiVezDG1f5MI"
Date: Fri, 22 Mar 2024 21:18:51 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"ttlSeconds":3600,"txId":"nOXJjj_vk0Dc1yCgdWD8kti_1iHruGzLQLNNBHVpN0Y","contractTxId":"bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM","type":"lease","owner":"QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ","endTimestamp":1711122739,"name":"ardrive"}%

dtfiedler added 10 commits March 21, 2024 20:27
Crude implmentation with O(n^2) complexity but works. Implementes API that returns relevant information for a record with headers
This will force records to expire on retrieval rather than manually deleting things on contract evaluation
This will ensure the TTL is always attached to the beginning of the buffer and the same size
@dtfiedler dtfiedler marked this pull request as ready for review March 22, 2024 20:02
dtfiedler added 2 commits March 22, 2024 14:05
@dtfiedler dtfiedler merged commit 2441f0c into develop Mar 22, 2024
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant