github.com/status-im/status-go@v1.1.0/protocol/peersyncing/sync_message.go (about) 1 package peersyncing 2 3 import "errors" 4 5 type SyncMessageType int 6 7 type SyncMessage struct { 8 ID []byte 9 Type SyncMessageType 10 ChatID []byte 11 Payload []byte 12 Timestamp uint64 13 } 14 15 var ErrSyncMessageNotValid = errors.New("sync message not valid") 16 17 func (s *SyncMessage) Valid() error { 18 valid := len(s.ID) != 0 && s.Type != SyncMessageNoType && len(s.ChatID) != 0 && len(s.Payload) != 0 && s.Timestamp != 0 19 if !valid { 20 return ErrSyncMessageNotValid 21 } 22 return nil 23 } 24 25 const ( 26 SyncMessageNoType SyncMessageType = iota 27 SyncMessageCommunityType 28 SyncMessageOneToOneType 29 SyncMessagePrivateGroup 30 )