Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions golpe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,6 @@ config:
- name: events__maxTagValSize
desc: "Maximum size for tag values, in bytes"
default: 1024
- name: events__archivalMode
desc: "Archival mode: no deleting of events"
default: false
19 changes: 12 additions & 7 deletions src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,11 @@ void writeEvents(lmdb::txn &txn, NegentropyFilterCache &neFilterCache, std::vect
if (isEventABeforeEventB(packed, otherPacked)) {
ev.status = EventWriteStatus::Replaced;
} else {
if (logDeletions) LI << "Deleting event (d-tag). id=" << to_hex(otherPacked.id());
levIdsToDelete.push_back(otherEv.primaryKeyId);
if (!cfg().events__archivalMode) {
if (logDeletions) LI << "Deleting event (d-tag). id=" << to_hex(otherPacked.id());
levIdsToDelete.push_back(otherEv.primaryKeyId);
}
}

return false;
}, true);

Expand Down Expand Up @@ -333,8 +334,10 @@ void writeEvents(lmdb::txn &txn, NegentropyFilterCache &neFilterCache, std::vect
if (tagName == 'e') {
auto otherEv = lookupEventById(txn, tagVal);
if (otherEv && PackedEventView(otherEv->buf).pubkey() == packed.pubkey()) {
if (logDeletions) LI << "Deleting event (kind 5, e-tag). id=" << to_hex(tagVal);
levIdsToDelete.push_back(otherEv->primaryKeyId);
if (!cfg().events__archivalMode) {
if (logDeletions) LI << "Deleting event (kind 5, e-tag). id=" << to_hex(tagVal);
levIdsToDelete.push_back(otherEv->primaryKeyId);
}
}
} else if (tagName == 'a') {
try { // parsing a-tag can fail
Expand All @@ -350,8 +353,10 @@ void writeEvents(lmdb::txn &txn, NegentropyFilterCache &neFilterCache, std::vect
auto otherPacked = PackedEventView(otherEv.buf);

if (otherPacked.created_at() <= packed.created_at()) {
if (logDeletions) LI << "Deleting replaceable event (kind 5, a-tag). id=" << to_hex(otherPacked.id());
levIdsToDelete.push_back(otherEv.primaryKeyId);
if (!cfg().events__archivalMode) {
if (logDeletions) LI << "Deleting replaceable event (kind 5, a-tag). id=" << to_hex(otherPacked.id());
levIdsToDelete.push_back(otherEv.primaryKeyId);
}
}

return false;
Expand Down
3 changes: 3 additions & 0 deletions strfry.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ events {

# Maximum size for tag values, in bytes
maxTagValSize = 1024

# Archival mode: no deleting of events
archivalMode = false
}

relay {
Expand Down