eventstore: remove useless sanity checking since event fields are already typed.
This commit is contained in:
@@ -3,7 +3,6 @@ package lmdb
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"iter"
|
"iter"
|
||||||
"math"
|
|
||||||
|
|
||||||
"fiatjaf.com/nostr"
|
"fiatjaf.com/nostr"
|
||||||
"fiatjaf.com/nostr/eventstore/internal"
|
"fiatjaf.com/nostr/eventstore/internal"
|
||||||
@@ -11,11 +10,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (b *LMDBBackend) ReplaceEvent(evt nostr.Event) error {
|
func (b *LMDBBackend) ReplaceEvent(evt nostr.Event) error {
|
||||||
// sanity checking
|
|
||||||
if evt.CreatedAt > math.MaxUint32 || evt.Kind > math.MaxUint16 {
|
|
||||||
return fmt.Errorf("event with values out of expected boundaries %d/%d", evt.CreatedAt, evt.Kind)
|
|
||||||
}
|
|
||||||
|
|
||||||
return b.lmdbEnv.Update(func(txn *lmdb.Txn) error {
|
return b.lmdbEnv.Update(func(txn *lmdb.Txn) error {
|
||||||
filter := nostr.Filter{Limit: 1, Kinds: []nostr.Kind{evt.Kind}, Authors: []nostr.PubKey{evt.PubKey}}
|
filter := nostr.Filter{Limit: 1, Kinds: []nostr.Kind{evt.Kind}, Authors: []nostr.PubKey{evt.PubKey}}
|
||||||
if evt.Kind.IsAddressable() {
|
if evt.Kind.IsAddressable() {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package lmdb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
|
|
||||||
"fiatjaf.com/nostr"
|
"fiatjaf.com/nostr"
|
||||||
"fiatjaf.com/nostr/eventstore"
|
"fiatjaf.com/nostr/eventstore"
|
||||||
@@ -11,11 +10,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (b *LMDBBackend) SaveEvent(evt nostr.Event) error {
|
func (b *LMDBBackend) SaveEvent(evt nostr.Event) error {
|
||||||
// sanity checking
|
|
||||||
if evt.CreatedAt > math.MaxUint32 || evt.Kind > math.MaxUint16 {
|
|
||||||
return fmt.Errorf("event with values out of expected boundaries %d/%d", evt.CreatedAt, evt.Kind)
|
|
||||||
}
|
|
||||||
|
|
||||||
return b.lmdbEnv.Update(func(txn *lmdb.Txn) error {
|
return b.lmdbEnv.Update(func(txn *lmdb.Txn) error {
|
||||||
if b.EnableHLLCacheFor != nil {
|
if b.EnableHLLCacheFor != nil {
|
||||||
// modify hyperloglog caches relative to this
|
// modify hyperloglog caches relative to this
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package mmm
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"iter"
|
"iter"
|
||||||
"math"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"fiatjaf.com/nostr"
|
"fiatjaf.com/nostr"
|
||||||
@@ -12,11 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (il *IndexingLayer) ReplaceEvent(evt nostr.Event) error {
|
func (il *IndexingLayer) ReplaceEvent(evt nostr.Event) error {
|
||||||
// sanity checking
|
|
||||||
if evt.CreatedAt > math.MaxUint32 || evt.Kind > math.MaxUint16 {
|
|
||||||
return fmt.Errorf("event with values out of expected boundaries")
|
|
||||||
}
|
|
||||||
|
|
||||||
il.mmmm.writeMutex.Lock()
|
il.mmmm.writeMutex.Lock()
|
||||||
defer il.mmmm.writeMutex.Unlock()
|
defer il.mmmm.writeMutex.Unlock()
|
||||||
|
|
||||||
|
|||||||
@@ -53,11 +53,6 @@ func (b *MultiMmapManager) storeOn(
|
|||||||
iltxns []*lmdb.Txn,
|
iltxns []*lmdb.Txn,
|
||||||
evt nostr.Event,
|
evt nostr.Event,
|
||||||
) (stored bool, err error) {
|
) (stored bool, err error) {
|
||||||
// sanity checking
|
|
||||||
if evt.CreatedAt > maxuint32 || evt.Kind > maxuint16 {
|
|
||||||
return false, fmt.Errorf("event with values out of expected boundaries")
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if we already have this id
|
// check if we already have this id
|
||||||
val, err := mmmtxn.Get(b.indexId, evt.ID[0:8])
|
val, err := mmmtxn.Get(b.indexId, evt.ID[0:8])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user