Browse Source

fix(curating): correct pubkey hash computation and UI field name

- Fix countEventsForPubkey to use SHA256 hash of pubkey (first 8 bytes)
  matching the PubHash type used in the Pubkey index
- Fix UI to use event_count field instead of total_events

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
main
woikos 4 months ago
parent
commit
c5be98bcaa
No known key found for this signature in database
  1. 2
      app/web/dist/bundle.js
  2. 2
      app/web/dist/bundle.js.map
  3. 2
      app/web/src/CurationView.svelte
  4. 10
      pkg/database/curating-acl.go

2
app/web/dist/bundle.js vendored

File diff suppressed because one or more lines are too long

2
app/web/dist/bundle.js.map vendored

File diff suppressed because one or more lines are too long

2
app/web/src/CurationView.svelte

@ -678,7 +678,7 @@ @@ -678,7 +678,7 @@
<div class="list-item">
<div class="item-main">
<span class="pubkey" title={user.pubkey}>{formatPubkey(user.pubkey)}</span>
<span class="event-count">{user.total_events} events</span>
<span class="event-count">{user.event_count} events</span>
</div>
<div class="item-actions">
<button class="btn-success" on:click={() => trustPubkey(user.pubkey, "")}>

10
pkg/database/curating-acl.go

@ -10,6 +10,7 @@ import ( @@ -10,6 +10,7 @@ import (
"time"
"github.com/dgraph-io/badger/v4"
"github.com/minio/sha256-simd"
)
// CuratingConfig represents the configuration for curating ACL mode
@ -1108,13 +1109,16 @@ func (c *CuratingACL) countEventsForPubkey(pubkeyHex string) (int, error) { @@ -1108,13 +1109,16 @@ func (c *CuratingACL) countEventsForPubkey(pubkeyHex string) (int, error) {
fmt.Sscanf(pubkeyHex[i*2:i*2+2], "%02x", &pubkeyBytes[i])
}
// Compute the pubkey hash (SHA256 of pubkey, first 8 bytes)
// This matches the PubHash type in indexes/types/pubhash.go
pkh := sha256.Sum256(pubkeyBytes)
// Scan the Pubkey index (prefix "pc-") for this pubkey
err := c.View(func(txn *badger.Txn) error {
// Build prefix: "pc-" + 8-byte pubkey hash
// The pubkey hash is the first 8 bytes of the pubkey
// Build prefix: "pc-" + 8-byte SHA256 hash of pubkey
prefix := make([]byte, 3+8)
copy(prefix[:3], []byte("pc-"))
copy(prefix[3:], pubkeyBytes[:8])
copy(prefix[3:], pkh[:8])
it := txn.NewIterator(badger.IteratorOptions{Prefix: prefix})
defer it.Close()

Loading…
Cancel
Save