implemented event and req
This commit is contained in:
@@ -30,9 +30,9 @@ func (ev *E) MarshalBinary(w io.Writer) {
|
||||
varint.Encode(w, uint64(ev.CreatedAt))
|
||||
varint.Encode(w, uint64(ev.Kind))
|
||||
varint.Encode(w, uint64(ev.Tags.Len()))
|
||||
for _, x := range ev.Tags.ToSliceOfTags() {
|
||||
for _, x := range *ev.Tags {
|
||||
varint.Encode(w, uint64(x.Len()))
|
||||
for _, y := range x.ToSliceOfBytes() {
|
||||
for _, y := range x.T {
|
||||
varint.Encode(w, uint64(len(y)))
|
||||
_, _ = w.Write(y)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoders.orly/hex"
|
||||
"encoders.orly/ints"
|
||||
"encoders.orly/text"
|
||||
"lol.mleku.dev/log"
|
||||
)
|
||||
|
||||
// ToCanonical converts the event to the canonical encoding used to derive the
|
||||
@@ -14,14 +15,15 @@ func (ev *E) ToCanonical(dst []byte) (b []byte) {
|
||||
b = append(b, "[0,\""...)
|
||||
b = hex.EncAppend(b, ev.Pubkey)
|
||||
b = append(b, "\","...)
|
||||
b = ints.New(ev.CreatedAt).Marshal(nil)
|
||||
b = ints.New(ev.CreatedAt).Marshal(b)
|
||||
b = append(b, ',')
|
||||
b = ints.New(ev.Kind).Marshal(nil)
|
||||
b = ints.New(ev.Kind).Marshal(b)
|
||||
b = append(b, ',')
|
||||
b = ev.Tags.Marshal(b)
|
||||
b = append(b, ',')
|
||||
b = text.AppendQuote(b, ev.Content, text.NostrEscape)
|
||||
b = append(b, ']')
|
||||
log.D.F("canonical: %s", b)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user