30
vendor/github.com/status-im/status-go/protocol/peersyncing/sync_message.go
generated
vendored
Normal file
30
vendor/github.com/status-im/status-go/protocol/peersyncing/sync_message.go
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
package peersyncing
|
||||
|
||||
import "errors"
|
||||
|
||||
type SyncMessageType int
|
||||
|
||||
type SyncMessage struct {
|
||||
ID []byte
|
||||
Type SyncMessageType
|
||||
GroupID []byte
|
||||
Payload []byte
|
||||
Timestamp uint64
|
||||
}
|
||||
|
||||
var ErrSyncMessageNotValid = errors.New("sync message not valid")
|
||||
|
||||
func (s *SyncMessage) Valid() error {
|
||||
valid := len(s.ID) != 0 && s.Type != SyncMessageNoType && len(s.GroupID) != 0 && len(s.Payload) != 0 && s.Timestamp != 0
|
||||
if !valid {
|
||||
return ErrSyncMessageNotValid
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
const (
|
||||
SyncMessageNoType SyncMessageType = iota
|
||||
SyncMessageCommunityType
|
||||
SyncMessageOneToOneType
|
||||
SyncMessagePrivateGroup
|
||||
)
|
||||
Reference in New Issue
Block a user