mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-24 12:40:46 +02:00
implement Stringer for Event.
This commit is contained in:
10
event.go
10
event.go
@@ -3,6 +3,7 @@ package nostr
|
|||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -41,6 +42,15 @@ const (
|
|||||||
KindZap int = 9735
|
KindZap int = 9735
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Event Stringer interface, just returns the raw JSON as a string
|
||||||
|
func (evt *Event) String() string {
|
||||||
|
if evt == nil {
|
||||||
|
return "null"
|
||||||
|
}
|
||||||
|
j, _ := json.Marshal(evt)
|
||||||
|
return string(j)
|
||||||
|
}
|
||||||
|
|
||||||
// GetID serializes and returns the event ID as a string
|
// GetID serializes and returns the event ID as a string
|
||||||
func (evt *Event) GetID() string {
|
func (evt *Event) GetID() string {
|
||||||
h := sha256.Sum256(evt.Serialize())
|
h := sha256.Sum256(evt.Serialize())
|
||||||
|
Reference in New Issue
Block a user