diff --git a/dev-docs/architecture.md b/dev-docs/architecture.md index 8224137..42b138f 100644 --- a/dev-docs/architecture.md +++ b/dev-docs/architecture.md @@ -138,7 +138,7 @@ Each store is a separate LevelDB with JSON values. Keys are txids, addresses, or | `status` | `status` | `syncedBlockHeight`, `chainBlockHeight`, `startBlockHeight` | | `posts` | txid | Author address, text, timestamp | | `postParents` | child txid | Parent txid (reply) | -| `postChildren` | parent txid | Reverse index for replies | +| `postChildren` | `parentTxid:childTxid` | One reply link per parent–child pair | | `likes` | like txid | Post txid, liker, optional tip | | `names` | address | Display name + provenance txid | | `profiles` | address | Profile text | diff --git a/dev-docs/psf-memo-db.md b/dev-docs/psf-memo-db.md index 8d9e44e..0727586 100644 --- a/dev-docs/psf-memo-db.md +++ b/dev-docs/psf-memo-db.md @@ -71,7 +71,7 @@ All routes are under `/level` with a consistent CRUD pattern generated from `ENT |-------|---------|-----------|-------------| | `post` | `txid` | `postData` | transaction id | | `postparent` | `txid` | `parentData` | child txid | -| `postchild` | `txid` | `childData` | parent txid | +| `postchild` | `key` | `childData` | `parentTxid:childTxid` | | `like` | `txid` | `likeData` | like txid | | `name` | `addr` | `nameData` | cash address | | `profile` | `addr` | `profileData` | cash address | @@ -187,7 +187,7 @@ Common fields on indexed documents: | profilePic | addr | `url`, `txid`, `seen`, `addr`, `blockHeight` | | like | txid | `addr`, `postTxid`, `seen`, `tip`, `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) | | processError | txid | `error`, `ts`, `blockHeight` | diff --git a/src/adapters/adapters-index.js b/src/adapters/adapters-index.js index 7d6f19b..dde951e 100644 --- a/src/adapters/adapters-index.js +++ b/src/adapters/adapters-index.js @@ -21,7 +21,7 @@ class Adapters { this.postDb = createEntityDb('post', 'txid', 'postData') 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.nameDb = createEntityDb('name', 'addr', 'nameData') this.profileDb = createEntityDb('profile', 'addr', 'profileData') diff --git a/src/use-cases/action-types/helpers.js b/src/use-cases/action-types/helpers.js index 0ef0f04..6a65987 100644 --- a/src/use-cases/action-types/helpers.js +++ b/src/use-cases/action-types/helpers.js @@ -57,3 +57,7 @@ export function followKey (followerAddr, followeeAddr) { export function roomKey (roomName, txid) { return `${roomName}:${txid}` } + +export function postChildKey (parentTxid, childTxid) { + return `${parentTxid}:${childTxid}` +} diff --git a/src/use-cases/action-types/reply.js b/src/use-cases/action-types/reply.js index 94cb2e6..bcb9920 100644 --- a/src/use-cases/action-types/reply.js +++ b/src/use-cases/action-types/reply.js @@ -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 { handlePost } from './post.js' @@ -24,7 +24,7 @@ export async function handleReply (ctx) { } 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]] } }) }