Daemons Search
This commit is contained in:
30
models/event.go
Normal file
30
models/event.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type Event struct {
|
||||
Type string `json:"type"`
|
||||
From string `json:"from"` // peerID
|
||||
|
||||
User string
|
||||
|
||||
DataType int64 `json:"datatype"`
|
||||
Timestamp int64 `json:"ts"`
|
||||
Payload []byte `json:"payload"`
|
||||
Signature []byte `json:"sig"`
|
||||
}
|
||||
|
||||
func (e *Event) RawEvent() *Event {
|
||||
return &Event{
|
||||
Type: e.Type,
|
||||
From: e.From,
|
||||
User: e.User,
|
||||
DataType: e.DataType,
|
||||
Timestamp: e.Timestamp,
|
||||
Payload: e.Payload,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Event) ToRawByte() ([]byte, error) {
|
||||
return json.Marshal(e.RawEvent())
|
||||
}
|
||||
Reference in New Issue
Block a user