Fixing reply overwrite issue

This commit is contained in:
Chris Troutner
2026-06-03 13:57:43 -07:00
parent 32e8e1f35f
commit e232a47ff9
5 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ Each store is a separate LevelDB with JSON values. Keys are txids, addresses, or
| `status` | `status` | `syncedBlockHeight`, `chainBlockHeight`, `startBlockHeight` | | `status` | `status` | `syncedBlockHeight`, `chainBlockHeight`, `startBlockHeight` |
| `posts` | txid | Author address, text, timestamp | | `posts` | txid | Author address, text, timestamp |
| `postParents` | child txid | Parent txid (reply) | | `postParents` | child txid | Parent txid (reply) |
| `postChildren` | parent txid | Reverse index for replies | | `postChildren` | `parentTxid:childTxid` | One reply link per parentchild pair |
| `likes` | like txid | Post txid, liker, optional tip | | `likes` | like txid | Post txid, liker, optional tip |
| `names` | address | Display name + provenance txid | | `names` | address | Display name + provenance txid |
| `profiles` | address | Profile text | | `profiles` | address | Profile text |
+2 -2
View File
@@ -71,7 +71,7 @@ All routes are under `/level` with a consistent CRUD pattern generated from `ENT
|-------|---------|-----------|-------------| |-------|---------|-----------|-------------|
| `post` | `txid` | `postData` | transaction id | | `post` | `txid` | `postData` | transaction id |
| `postparent` | `txid` | `parentData` | child txid | | `postparent` | `txid` | `parentData` | child txid |
| `postchild` | `txid` | `childData` | parent txid | | `postchild` | `key` | `childData` | `parentTxid:childTxid` |
| `like` | `txid` | `likeData` | like txid | | `like` | `txid` | `likeData` | like txid |
| `name` | `addr` | `nameData` | cash address | | `name` | `addr` | `nameData` | cash address |
| `profile` | `addr` | `profileData` | cash address | | `profile` | `addr` | `profileData` | cash address |
@@ -187,7 +187,7 @@ Common fields on indexed documents:
| profilePic | addr | `url`, `txid`, `seen`, `addr`, `blockHeight` | | profilePic | addr | `url`, `txid`, `seen`, `addr`, `blockHeight` |
| like | txid | `addr`, `postTxid`, `seen`, `tip`, `blockHeight` | | like | txid | `addr`, `postTxid`, `seen`, `tip`, `blockHeight` |
| follow | composite key | `followerAddr`, `followeePkHash`, `unfollow`, `txid`, `seen`, `blockHeight` | | follow | composite key | `followerAddr`, `followeePkHash`, `unfollow`, `txid`, `seen`, `blockHeight` |
| postParent / postChild | txid | `parentTxid`, `childTxid`, `blockHeight` | | postParent / postChild | txid / `parentTxid:childTxid` | `parentTxid`, `childTxid`, `blockHeight` |
| room | composite key | `room`, `txid`, `seen`, `type`, `blockHeight` (+ `addr` for follows) | | room | composite key | `room`, `txid`, `seen`, `type`, `blockHeight` (+ `addr` for follows) |
| processError | txid | `error`, `ts`, `blockHeight` | | processError | txid | `error`, `ts`, `blockHeight` |
+1 -1
View File
@@ -21,7 +21,7 @@ class Adapters {
this.postDb = createEntityDb('post', 'txid', 'postData') this.postDb = createEntityDb('post', 'txid', 'postData')
this.postParentDb = createEntityDb('postparent', 'txid', 'parentData') this.postParentDb = createEntityDb('postparent', 'txid', 'parentData')
this.postChildDb = createEntityDb('postchild', 'txid', 'childData') this.postChildDb = createEntityDb('postchild', 'key', 'childData')
this.likeDb = createEntityDb('like', 'txid', 'likeData') this.likeDb = createEntityDb('like', 'txid', 'likeData')
this.nameDb = createEntityDb('name', 'addr', 'nameData') this.nameDb = createEntityDb('name', 'addr', 'nameData')
this.profileDb = createEntityDb('profile', 'addr', 'profileData') this.profileDb = createEntityDb('profile', 'addr', 'profileData')
+4
View File
@@ -57,3 +57,7 @@ export function followKey (followerAddr, followeeAddr) {
export function roomKey (roomName, txid) { export function roomKey (roomName, txid) {
return `${roomName}:${txid}` return `${roomName}:${txid}`
} }
export function postChildKey (parentTxid, childTxid) {
return `${parentTxid}:${childTxid}`
}
+2 -2
View File
@@ -1,4 +1,4 @@
import { utf8FromPush, txHashFromPush, logProcessError } from './helpers.js' import { utf8FromPush, txHashFromPush, logProcessError, postChildKey } from './helpers.js'
import { MAX_REPLY_SIZE } from '../../lib/memo-codes.js' import { MAX_REPLY_SIZE } from '../../lib/memo-codes.js'
import { handlePost } from './post.js' import { handlePost } from './post.js'
@@ -24,7 +24,7 @@ export async function handleReply (ctx) {
} }
await adapters.postParentDb.create(txid, { parentTxid, childTxid: txid, blockHeight }) await adapters.postParentDb.create(txid, { parentTxid, childTxid: txid, blockHeight })
await adapters.postChildDb.create(parentTxid, { parentTxid, childTxid: txid, blockHeight }) await adapters.postChildDb.create(postChildKey(parentTxid, txid), { parentTxid, childTxid: txid, blockHeight })
await handlePost({ ...ctx, decoded: { ...decoded, pushDatas: [pushDatas[0], pushDatas[2]] } }) await handlePost({ ...ctx, decoded: { ...decoded, pushDatas: [pushDatas[0], pushDatas[2]] } })
} }