mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-02 11:31:01 +02:00
style: using effective go and refactoring
This commit is contained in:
6
event.go
6
event.go
@ -58,13 +58,13 @@ const (
|
||||
KindApplicationSpecificData int = 30078
|
||||
)
|
||||
|
||||
// Event Stringer interface, just returns the raw JSON as a string
|
||||
// Event Stringer interface, just returns the raw JSON as a string.
|
||||
func (evt Event) String() string {
|
||||
j, _ := easyjson.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 {
|
||||
h := sha256.Sum256(evt.Serialize())
|
||||
return hex.EncodeToString(h[:])
|
||||
@ -128,7 +128,7 @@ func (evt Event) CheckSignature() (bool, error) {
|
||||
return sig.Verify(hash[:], pubkey), nil
|
||||
}
|
||||
|
||||
// Sign signs an event with a given privateKey
|
||||
// Sign signs an event with a given privateKey.
|
||||
func (evt *Event) Sign(privateKey string) error {
|
||||
s, err := hex.DecodeString(privateKey)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user