31 lines
553 B
Go
31 lines
553 B
Go
|
|
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())
|
||
|
|
}
|