Content
@
https://warpcast.com/~/channel/fc-devs
0 reply
0 recast
0 reaction
christopher
@christopher
So open mental note here to not get clever and use the first 6 characters of a cast because it will collide.. i.e. 0xabcdef vs. 0xabcdef12 π Collision probability with 100,000 casts: - 6 characters: ~37% chance of at least one collision. - 8 characters: ~0.12% chance of at least one collision.
1 reply
0 recast
12 reactions
christopher
@christopher
Donβt learn the hard way.
1 reply
0 recast
2 reactions
artlu π©
@artlu
isn't the idea that the username is part of the shorthash?
2 replies
0 recast
0 reaction
Andrei O.
@andrei0x309
No, username is not part of the hash but is part of the query. They use both the username and short hash, which practically forms a composite key with improbable collision. They could use the full hash as @christopher says, also a composite key can be faster, but not in all scenarios. It can also be slower depending on DB and implementation, and it also might require additional storage with little benefit. What I think is the real reason is that they wanted to have a nice URL, that doesn't contain the hash in full form. Again without full source code, everything related to the client is speculation.
1 reply
0 recast
1 reaction
christopher
@christopher
Hmmm not sure if username is part of the query because usernames do change over time. But fid could/should be. cc @cmlad.eth @sds
1 reply
0 recast
1 reaction
Andrei O.
@andrei0x309
That's what the REST endpoint that Warpcast uses suggests: ``` getCastThread = async ({ castHash, limit = 15, username, cursor = '' }: { castHash: string, username: string, limit: number, cursor?: string }) => { const response = await fetch(`${this._apiEndpointBase}/user-thread-casts?castHashPrefix=${castHash}&username=${username}&limit=${limit}${cursor ? `&cursor=${cursor}` : ''}`, { method: 'GET', headers: this.headers }); return await response.json() as TWcUserThreadItems } ``` The username may change true but when it does the change will also be picked up and and probably synced with the DB. Now we don't know how the username and hash prefixed are used on the backend(since is not open) but those are used at least in the REST query if not in the DB query.
1 reply
0 recast
2 reactions