Repository navigation
Track entity manager - #3706
Track entity manager#3706
Conversation
| } | ||
|
|
||
| // Minimum track ID, intentionally higher than legacy track ID range | ||
| static MIN_TRACK_ID = 1000000 |
There was a problem hiding this comment.
this is too low https://discoveryprovider.audius.co/latest/track
| static MIN_TRACK_ID = 1000000 | ||
|
|
||
| // Maximum track ID, reflects postgres max integer value | ||
| static MAX_TRACK_ID = 2147483647 |
There was a problem hiding this comment.
Can you confirm that 2147483647 is not too big to cause any sort of collision with our hash id stuff? My best guess is we have 5 letters BqN19 so 62 ^ 5 which is less than 2 billion
There was a problem hiding this comment.
i think it works! 5 is just min length and 2147483647 encodes to a 7 letter string
There are no collisions because the method is based on integer to hex conversion. As long as you don't change constructor arguments midway, the generated output will stay unique to your salt.
| let trackId: number | ||
| if (useEntityManager) { | ||
| trackId = Track.generateTrackId() | ||
| const response = await this.contracts.EntityManagerClient!.manageEntity( |
There was a problem hiding this comment.
for subsequent changes should we modify existing files like this? maybe entityManager.ts functions should move over to playlist.
There was a problem hiding this comment.
yeah, that was what I was thinking too, can make that change later though
| trackFile: File, | ||
| coverArtFile: File, | ||
| metadata: TrackMetadata, | ||
| async uploadTrack({ |
There was a problem hiding this comment.
is there a way we are tracking these api changes for when we update in audius-client?
There was a problem hiding this comment.
Yes, this seemed scary to me in the case that we revert the libs version and not doing it atomically with the client change. I have the client changes out in PR already too. will try to merge together with libs update
| // Associate the track id with the file metadata and block number | ||
| await this.creatorNode.associateTrack( | ||
| trackId, | ||
| trackId!, |
There was a problem hiding this comment.
is there a clean way to avoid using !, like having if checks and error logs if they aren't there?
| async addTracksToChainAndCnode(trackMultihashAndUUIDList: ChainInfo[]) { | ||
| async addTracksToChainAndCnode( | ||
| trackMultihashAndUUIDList: ChainInfo[], | ||
| useEntityManager: boolean |
There was a problem hiding this comment.
would it make sense adding useEntityManager as a field on the Track api to internally reference on these methods? or do we want to specify this boolean for each method call?
There was a problem hiding this comment.
could go either way on it, I personally like the ability to use either for testing, but in practice would be easier to set internally.
| if (useEntityManager) { | ||
| trackId = Track.generateTrackId() | ||
| const response = | ||
| await this.contracts.EntityManagerClient!.manageEntity( |
There was a problem hiding this comment.
just wondering why it's nullable here and if there is anything clever we can do about it, nbd tho
There was a problem hiding this comment.
Because we are adding a new contract, the entity manager addr might not be passed in and is nullable - https://github.com/AudiusProject/audius-protocol/blob/7c68b2a99e1942173664a26a97f2b9432cb60ca3/libs/src/services/dataContracts/AudiusContracts.ts#L48
8e01df0 to
f88e426
Compare
Description
Adds the boolean
useEntityManagerto the libs Tracks service so that the new contract will conditionally be used based on this boolean.Note, this updates the method parameters:
uploadTrack: Updates arguments to be object detructedupdateTrack: Updates arguments to add a second param for the booleandeleteTrack: Updates arguments to add a second param for the booleanTests
Ran locally against linked like with and without the boolean set
Monitoring - How will this change be monitored? Are there sufficient logs / alerts?