mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-18 13:53:03 +01:00
36 lines
694 B
Go
36 lines
694 B
Go
package binary
|
|
|
|
import (
|
|
"math"
|
|
|
|
"github.com/nbd-wtf/go-nostr"
|
|
)
|
|
|
|
const (
|
|
MaxKind = math.MaxUint16
|
|
MaxCreatedAt = math.MaxUint32
|
|
MaxContentSize = math.MaxUint16
|
|
MaxTagCount = math.MaxUint16
|
|
MaxTagItemCount = math.MaxUint8
|
|
MaxTagItemSize = math.MaxUint16
|
|
)
|
|
|
|
func EventEligibleForBinaryEncoding(event *nostr.Event) bool {
|
|
if len(event.Content) > MaxContentSize || event.Kind > MaxKind || event.CreatedAt > MaxCreatedAt || len(event.Tags) > MaxTagCount {
|
|
return false
|
|
}
|
|
|
|
for _, tag := range event.Tags {
|
|
if len(tag) > MaxTagItemCount {
|
|
return false
|
|
}
|
|
for _, item := range tag {
|
|
if len(item) > MaxTagItemSize {
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|