entities

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2024 License: LGPL-2.1 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlatformEthereum string = "ethereum"
	PlatformBitcoin         = "bitcoin"
	PlatformSolana          = "solana"
	PlatformCosmos          = "cosmos"
)

Variables

This section is empty.

Functions

func GetId

func GetId(d Payload) (string, error)

func SubnetToByte

func SubnetToByte(i uint64) []byte

func TopicToByte

func TopicToByte(i uint64) []byte

Types

type Authorization

type Authorization struct {
	ID            string                           `json:"id" gorm:"type:uuid;not null;primaryKey"`
	Agent         DeviceString                     `json:"agt" gorm:"uniqueIndex:idx_agent_account"`
	Meta          string                           `json:"meta,omitempty"`
	Account       DIDString                        `json:"acct" gorm:"varchar(40),uniqueIndex:idx_agent_account"`
	Grantor       DIDString                        `json:"gr" gorm:"index"`
	Priviledge    constants.AuthorizationPrivilege `json:"privi"`
	TopicIds      string                           `json:"topIds"`
	Timestamp     uint64                           `json:"ts"`
	Duration      uint64                           `json:"du"`
	SignatureData SignatureData                    `json:"sigD" gorm:"json;"`
	Hash          string                           `json:"h" gorm:"unique" `
	Event         EventPath                        `json:"e,omitempty" gorm:"index;varchar;"`
	Subnet        string                           `json:"snet" gorm:"index;char(36)"`
}

func (Authorization) EncodeBytes

func (g Authorization) EncodeBytes() ([]byte, error)

func (Authorization) GetAgent

func (entity Authorization) GetAgent() DeviceString

func (Authorization) GetEvent

func (entity Authorization) GetEvent() EventPath

func (Authorization) GetHash

func (g Authorization) GetHash() ([]byte, error)

func (Authorization) ToJSON

func (g Authorization) ToJSON() []byte

func (Authorization) ToString

func (g Authorization) ToString() string

type Block

type Block struct {
	BlockId    string `json:"blId"`
	Size       int    `json:"s"`
	Closed     bool   `json:"c"`
	NodeHeight uint64 `json:"nh"`
	Hash       string `json:"h"`
	Timestamp  int    `json:"ts"`
	sync.Mutex
}

Block

func BlockFromBytes

func BlockFromBytes(b []byte) (*Block, error)

func NewBlock

func NewBlock() *Block

func UnpackBlock

func UnpackBlock(b []byte) (*Block, error)

func (*Block) Key

func (msg *Block) Key() string

func (*Block) MsgPack

func (msg *Block) MsgPack() []byte

func (*Block) ToString

func (msg *Block) ToString() string

type ClientHandshake

type ClientHandshake struct {
	Signature string    `json:"sig"`
	Signer    DIDString `json:"sigr"`
	// Message   string          `json:"m"`
	Protocol     constants.Protocol `json:"proto"`
	ClientSocket *interface{}       `json:"ws"`
	Timestamp    int64              `json:"ts"`
}

func UnpackClientHandshake

func UnpackClientHandshake(b []byte) (ClientHandshake, error)

func (ClientHandshake) EncodeBytes

func (cs ClientHandshake) EncodeBytes() ([]byte, error)

func (*ClientHandshake) MsgPack

func (hs *ClientHandshake) MsgPack() []byte

func (ClientHandshake) ToJSON

func (cs ClientHandshake) ToJSON() []byte

type ClientPayload

type ClientPayload struct {
	// Primary
	Data      interface{} `json:"d"`
	Timestamp int         `json:"ts"`
	EventType uint16      `json:"ty"`
	Nonce     uint64      `json:"nonce"`
	Account   DIDString   `json:"acct,omitempty"` // optional public key of sender

	Validator PublicKeyString `json:"val,omitempty"`
	// Secondary																								 	AA	`							qaZAA	`q1aZaswq21“		`	`
	Signature string       `json:"sig"`
	Hash      string       `json:"h,omitempty"`
	Agent     DeviceString `gorm:"-" json:"agt"`
	Subnet    string       `json:"snet" gorm:"index;"`
	Page      uint16       `json:"page,omitempty" gorm:"_"`
	PerPage   uint16       `json:"perPage,omitempty" gorm:"_"`
}

func ClientPayloadFromBytes

func ClientPayloadFromBytes(b []byte) (ClientPayload, error)

func MsgUnpackClientPayload

func MsgUnpackClientPayload(b []byte) (ClientPayload, error)

func (ClientPayload) EncodeBytes

func (msg ClientPayload) EncodeBytes() ([]byte, error)

func (ClientPayload) GetHash

func (msg ClientPayload) GetHash() ([]byte, error)

func (ClientPayload) GetSigner

func (msg ClientPayload) GetSigner() (DeviceString, error)

func (*ClientPayload) MsgPack

func (s *ClientPayload) MsgPack() []byte

func (ClientPayload) ToJSON

func (msg ClientPayload) ToJSON() []byte

func (ClientPayload) ToString

func (msg ClientPayload) ToString() string

type ClientResponse

type ClientResponse struct {
	Data  any    `json:"data"`
	Error string `json:"error,omitempty"`

	Meta ResponseMeta `json:"_meta"`
}

func NewClientResponse

func NewClientResponse(cr ClientResponse) ClientResponse

func (ClientResponse) ToMap

func (cr ClientResponse) ToMap() map[string]any

type ConnectionState

type ConnectionState uint8
const (
	OfflineState ConnectionState = 0
	OnlineState  ConnectionState = 1
)

type DID

type DID struct {
	Prefix string `json:"pre"`
	Addr   string `json:"addr"`
	// Platform string    `json:"p"`
	Chain string `json:"ch"`
}

func AddressFromBytes

func AddressFromBytes(b []byte) (DID, error)

func AddressFromString

func AddressFromString(s string) DID

func MsgUnpack

func MsgUnpack(b []byte) (DID, error)

func (*DID) GetHash

func (address *DID) GetHash() []byte

func (*DID) MsgPack

func (address *DID) MsgPack() []byte

func (*DID) ToBytes

func (address *DID) ToBytes() []byte

func (DID) ToDeviceString

func (address DID) ToDeviceString() DeviceString

func (*DID) ToJSON

func (address *DID) ToJSON() []byte

func (DID) ToString

func (address DID) ToString() DIDString

type DIDString

type DIDString string

func (*DIDString) ToString

func (address *DIDString) ToString() string

type DataType

type DataType string
const (
	DataTypeBinary DataType = "application/octet-stream"
	DataTypeText   DataType = "text/plain"
	DataTypeJSON   DataType = "text/json"
	DataTypePNG    DataType = "image/png"
	DataTypeJPG    DataType = "image/jpg"
)

type DeliveryClaim

type DeliveryClaim struct {
	NodeHeight int      `json:"nh"`
	Signature  string   `json:"sig"`
	Amount     string   `json:"a"`
	Proofs     []string `json:"prs"`
}

DeliveryClaim

func DeliveryClaimFromBytes

func DeliveryClaimFromBytes(b []byte) (DeliveryClaim, error)

func UnpackDelvieryClaim

func UnpackDelvieryClaim(b []byte) (DeliveryClaim, error)

func (*DeliveryClaim) ToJSON

func (msg *DeliveryClaim) ToJSON() []byte

type DeliveryProof

type DeliveryProof struct {
	MessageHash   string `json:"mH"`
	MessageSender string `json:"mS"`
	NodeAddress   string `json:"nA"`
	Timestamp     int    `json:"ts"`
	Signature     string `json:"sig"`
	Block         string `json:"bl"`
	Index         int    `json:"i"`
}

DeliveryProof

func DeliveryProofFromBytes

func DeliveryProofFromBytes(b []byte) (DeliveryProof, error)

func (*DeliveryProof) BlockKey

func (msg *DeliveryProof) BlockKey() string

func (DeliveryProof) EncodeBytes

func (msg DeliveryProof) EncodeBytes() ([]byte, error)

func (*DeliveryProof) Key

func (msg *DeliveryProof) Key() string

func (*DeliveryProof) MsgPack

func (msg *DeliveryProof) MsgPack() []byte

func (*DeliveryProof) ToJSON

func (msg *DeliveryProof) ToJSON() []byte

func (DeliveryProof) ToString

func (msg DeliveryProof) ToString() string

type DeviceString

type DeviceString DIDString

type ErrorResponse

type ErrorResponse struct {
	// contains filtered or unexported fields
}

func ReturnError

func ReturnError(msg string, code int) *ErrorResponse

type Event

type Event struct {
	// Primary
	ID string `gorm:"primaryKey;type:uuid;not null" json:"id,omitempty"`

	Payload           ClientPayload `json:"pld" gorm:"serializer:json" msgpack:",noinline"`
	Nonce             string        `json:"nonce" gorm:"type:varchar(80);uniqueIndex:idx_nonce_hash;default:null" msgpack:",noinline"`
	Timestamp         uint64        `json:"ts"`
	EventType         uint16        `json:"t"`
	Associations      []string      `json:"assoc" gorm:"type:text[]"`
	PreviousEventHash EventPath     `json:"preE" gorm:"type:varchar;default:null"`
	AuthEventHash     EventPath     `json:"authE" gorm:"type:varchar;default:null"`
	PayloadHash       string        `json:"pH" gorm:"type:char(64);unique"`
	// StateHash string `json:"sh"`
	// Secondary
	Error       string          `json:"err"`
	Hash        string          `json:"h" gorm:"uniqueIndex:idx_nonce_hash;type:char(64)"`
	Signature   string          `json:"sig"`
	Broadcasted bool            `json:"br"`
	BlockNumber uint64          `json:"blk"`
	IsValid     bool            `json:"isVal" gorm:"default:false"`
	Synced      bool            `json:"sync" gorm:"default:false"`
	Validator   PublicKeyString `json:"val"`

	Total int `json:"total"`
}

func EventFromJSON

func EventFromJSON(b []byte) (Event, error)

func UnpackEvent

func UnpackEvent[DataType any](b []byte, data *DataType) (*Event, error)

func WalletBalanceFromJSON

func WalletBalanceFromJSON(b []byte) (Event, error)

func WalletFromJSON

func WalletFromJSON(b []byte) (Event, error)

func (*Event) BeforeCreate

func (d *Event) BeforeCreate(tx *gorm.DB) (err error)

func (Event) EncodeBytes

func (e Event) EncodeBytes() ([]byte, error)

func (Event) GetHash

func (e Event) GetHash() ([]byte, error)

func (Event) GetSignature

func (e Event) GetSignature() string

func (Event) GetValidator

func (e Event) GetValidator() PublicKeyString

func (*Event) Key

func (e *Event) Key() string

func (*Event) MsgPack

func (e *Event) MsgPack() []byte

func (*Event) ToJSON

func (e *Event) ToJSON() []byte

func (Event) ToString

func (e Event) ToString() string

type EventInterface

type EventInterface interface {
	EncodeBytes() ([]byte, error)
	GetValidator() PublicKeyString
	GetSignature() string
}

type EventModel

type EventModel string
const (
	AuthEventModel         EventModel = "auth"
	TopicEventModel        EventModel = "top"
	SubscriptionEventModel EventModel = "sub"
	MessageEventModel      EventModel = "msg"
	SubnetEventModel       EventModel = "subnet"
	WalletEventModel       EventModel = "wal"
)

type EventPath

type EventPath struct {
	Model     EventModel      `json:"mod"`
	Hash      string          `json:"h"`
	Validator PublicKeyString `json:"val"`
}

* Event paths define the unique path to an event and its relation to the entitie

*

func EventPathFromString

func EventPathFromString(path string) *EventPath

func NewEventPath

func NewEventPath(validator PublicKeyString, model EventModel, hash string) *EventPath

func (EventPath) GormDataType

func (eP EventPath) GormDataType() string

func (EventPath) GormValue

func (eP EventPath) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (*EventPath) Scan

func (sD *EventPath) Scan(value interface{}) error

func (*EventPath) ToString

func (e *EventPath) ToString() string

func (*EventPath) Value

func (sD *EventPath) Value() (driver.Value, error)

type Handshake

type Handshake struct {
	Data      HandshakeData `json:"data"`
	Signature string        `json:"s"`
	Signer    string        `json:"sigr"`
}

func CreateHandshake

func CreateHandshake(name string, network string, privateKey string, nodeType uint) (Handshake, error)

func HandshakeFromBytes

func HandshakeFromBytes(b []byte) Handshake

func HandshakeFromJSON

func HandshakeFromJSON(json string) (Handshake, error)

func HandshakeFromString

func HandshakeFromString(hs string) Handshake

func UnpackHandshake

func UnpackHandshake(b []byte) (Handshake, error)

func (*Handshake) Init

func (hs *Handshake) Init(jsonString string) error

func (*Handshake) MsgPack

func (hs *Handshake) MsgPack() []byte

func (*Handshake) ToJSON

func (hs *Handshake) ToJSON() []byte

type HandshakeData

type HandshakeData struct {
	Timestamp  int    `json:"ts"`
	ProtocolId string `json:"proId"`
	Name       string `json:"n"`
	NodeType   uint   `json:"nT"`
}

* NODE ANDSHAKE MESSAGE *

func (HandshakeData) EncodeBytes

func (hsd HandshakeData) EncodeBytes() ([]byte, error)

func (*HandshakeData) ToJSON

func (hsd *HandshakeData) ToJSON() []byte

func (HandshakeData) ToString

func (hsd HandshakeData) ToString() string

type MainStat

type MainStat struct {
	Accounts     int64    `json:"accounts"`
	TopicBalance int64    `json:"topic_balance"`
	Messages     int64    `json:"messages"`
	MessageCount *big.Int `json:"message_cost"`
}

type Message

type Message struct {
	ID string `json:"id" gorm:"type:uuid;primaryKey;not null"`
	// Timestamp      uint64   `json:"ts"`
	TopicId string    `json:"topId,omitempty"`
	Sender  DIDString `json:"s"`
	// OwnerAddress  string              `json:"oA"`
	Receiver DIDString       `json:"r,omitempty"`
	Data     string          `json:"d"`
	DataType string          `json:"dTy"`
	Actions  []MessageAction `json:"a" gorm:"json;"`
	// Length int `json:"len"`
	Agent DeviceString `json:"agt,omitempty" binding:"required"  gorm:"not null;type:varchar(100)"`

	/// DERIVED
	Event       EventPath           `json:"e,omitempty" gorm:"index;char(64);"`
	Hash        string              `json:"h"`
	Attachments []MessageAttachment `json:"atts" gorm:"json;"`
	// Subject     string              `json:"s"`
	Signature string `json:"sig"`
	// Origin      string              `json:"o"`
	DataHash string `json:"dH"`
	Url      string `json:"url"`
}

func MessageFromBytes

func MessageFromBytes(b []byte) Message

func MessageFromString

func MessageFromString(msg string) Message

func (Message) EncodeBytes

func (msg Message) EncodeBytes() ([]byte, error)

func (Message) GetAgent

func (entity Message) GetAgent() DeviceString

func (Message) GetEvent

func (entity Message) GetEvent() EventPath

func (Message) GetHash

func (msg Message) GetHash() ([]byte, error)

func (*Message) MsgPack

func (msg *Message) MsgPack() []byte

func (*Message) ToJSON

func (msg *Message) ToJSON() string

func (Message) ToString

func (chatMessage Message) ToString() string

type MessageAction

type MessageAction struct {
	Contract   string   `json:"c"`
	Abi        string   `json:"abi"`
	Action     string   `json:"a"`
	Parameters []string `json:"pa"`
}

func (MessageAction) EncodeBytes

func (a MessageAction) EncodeBytes() []byte

type MessageAttachment

type MessageAttachment struct {
	CID  string `json:"cid"`
	Hash string `json:"h"`
}

func (MessageAttachment) EncodeBytes

func (b MessageAttachment) EncodeBytes() []byte

type Meta

type Meta struct {
	// contains filtered or unexported fields
}

type Payload

type Payload interface {
	GetHash() ([]byte, error)
	ToString() string
	EncodeBytes() ([]byte, error)
	GetEvent() EventPath
}

type Presence

type Presence struct {
	Account         DIDString       `json:"acct"`
	MetaData        json.RawMessage `json:"metaD"`
	ConnectionState ConnectionState `json:"connS"`
	ActiveAgo       uint64          `json:"actA"`
}

type PubKeyType

type PubKeyType string
const (
	TendermintsSecp256k1PubKey PubKeyType = "tendermint/PubKeySecp256k1"
	EthereumPubKey             PubKeyType = "ethereum"
)

type PubSubMessage

type PubSubMessage struct {
	Data msgpack.RawMessage `json:"d"`
}

PubSubMessage

func NewPubSubMessage

func NewPubSubMessage(data []byte) PubSubMessage

func PubSubMessageFromBytes

func PubSubMessageFromBytes(b []byte) (PubSubMessage, error)

func UnpackPubSubMessage

func UnpackPubSubMessage(b []byte) (PubSubMessage, error)

func (*PubSubMessage) EncodeBytes

func (msg *PubSubMessage) EncodeBytes() ([]byte, error)

func (*PubSubMessage) MsgPack

func (msg *PubSubMessage) MsgPack() []byte

func (*PubSubMessage) ToJSON

func (msg *PubSubMessage) ToJSON() []byte

func (*PubSubMessage) ToString

func (msg *PubSubMessage) ToString() string

type PublicKeyString

type PublicKeyString string

type ResponseInterval

type ResponseInterval struct {
	FromTime  uint64 `json:"fromT,omitempty"`
	ToTime    uint64 `json:"toT,omitempty"`
	FromBlock uint64 `json:"fromB,omitempty"`
	ToBlock   uint64 `json:"toB,omitempty"`
}

type ResponseMeta

type ResponseMeta struct {
	Page    uint   `json:"page,omitempty"`
	PerPage uint   `json:"perPage,omitempty"`
	Count   uint   `json:"count,omitempty"`
	Version string `json:"version,omitempty"`
}

type ResponsePayload

type ResponsePayload interface {
	GetHash() ([]byte, error)
	ToString() string
	EncodeBytes() ([]byte, error)
}

type ServerIdentity

type ServerIdentity struct {
	Signature string `json:"sig"`
	Signer    string `json:"sigr"`
	Message   string `json:"m"`
	Address   string `json:"addr"`
}

func UnpackServerIdentity

func UnpackServerIdentity(b []byte) (ServerIdentity, error)

func (*ServerIdentity) MsgPack

func (hs *ServerIdentity) MsgPack() []byte

type SignatureData

type SignatureData struct {
	Type      PubKeyType `json:"ty"`
	PublicKey string     `json:"pubK,omitempty"`
	Signature string     `json:"sig"`
}

func (SignatureData) GormDataType

func (sD SignatureData) GormDataType() string

func (SignatureData) GormValue

func (sD SignatureData) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (*SignatureData) Scan

func (sD *SignatureData) Scan(value interface{}) error

func (*SignatureData) Value

func (sD *SignatureData) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Stats

type Stats struct {
	ID                 string `json:"id" gorm:"type:uuid;primaryKey;not null"`
	BlockNumber        uint64 `json:"blk"`
	EventCount         uint64 `json:"eC"`
	MessageCount       uint64 `json:"mC"`
	TopicCount         uint64 `json:"tC"`
	AuthorizationCount uint64 `json:"authC"`
	Cycle              uint64 `json:"cy"`
	Epoch              uint64 `json:"ep"`
	MessageCost        string `json:"mCo"`
}

type Subnet

type Subnet struct {
	ID            string        `json:"id" gorm:"type:uuid;primaryKey;not null"`
	Meta          string        `json:"meta,omitempty"`
	Ref           string        `json:"ref,omitempty"  gorm:"unique;type:varchar(64);default:null"`
	Categories    pq.Int32Array `gorm:"type:integer[]"`
	Owner         DIDString     `json:"own,omitempty" binding:"required"  gorm:"not null;type:varchar(100)"`
	SignatureData SignatureData `json:"sigD" gorm:"json;"`
	Status        uint8         `json:"st" gorm:"boolean;default:0"`
	Timestamp     uint64        `json:"ts,omitempty" binding:"required"`
	Balance       uint64        `json:"bal" gorm:"default:0"`
	// Readonly
	Account DIDString    `json:"acct,omitempty" binding:"required"  gorm:"not null;type:varchar(100)"`
	Agent   DeviceString `json:"_"  gorm:"_"`

	// Derived
	Event EventPath `json:"e,omitempty" gorm:"index;varchar;"`
	Hash  string    `json:"h,omitempty" gorm:"type:char(64)"`
}

func SubnetFromBytes

func SubnetFromBytes(b []byte) (Subnet, error)

func UnpackSubnet

func UnpackSubnet(b []byte) (Subnet, error)

func (*Subnet) CanSend

func (p *Subnet) CanSend(channel string, sender DIDString) bool

func (Subnet) EncodeBytes

func (item Subnet) EncodeBytes() ([]byte, error)

func (Subnet) GetAgent

func (entity Subnet) GetAgent() DeviceString

func (Subnet) GetEvent

func (entity Subnet) GetEvent() EventPath

func (Subnet) GetHash

func (item Subnet) GetHash() ([]byte, error)

func (*Subnet) IsMember

func (p *Subnet) IsMember(channel string, sender DIDString) bool

func (*Subnet) Key

func (item *Subnet) Key() string

func (*Subnet) MsgPack

func (item *Subnet) MsgPack() []byte

func (*Subnet) ToJSON

func (item *Subnet) ToJSON() []byte

func (Subnet) ToString

func (item Subnet) ToString() string

type Subscription

type Subscription struct {
	ID         string    `gorm:"primaryKey;type:char(36);not null"   json:"id,omitempty"`
	Topic      string    `json:"top" form:"top"   gorm:"not null;uniqueIndex:idx_sub_topic;type:char(36);index"`
	Ref        string    `json:"ref" gorm:"unique;type:varchar(100)"`
	Meta       string    `json:"meta"  gorm:"type:varchar(100);"`
	Subnet     string    `json:"snet"  gorm:"not null;uniqueIndex:idx_ref_subnet;type:varchar(36);index"`
	Subscriber DIDString `json:"sub"  gorm:"not null;uniqueIndex:idx_sub_topic;type:varchar(100);index"`
	// Device     DeviceString                  `json:"dev,omitempty" binding:"required"  gorm:"not null;uniqueIndex:idx_acct_dev_topic;type:varchar(100);index"`
	Status constants.SubscriptionStatuses `json:"st"  gorm:"not null;type:smallint;default:2"`
	Role   constants.SubscriberPrivilege  `json:"rol" gorm:"default:0"`

	// Signature string                         `json:"sig"`
	Timestamp uint64       `json:"ts"`
	Hash      string       `json:"h" gorm:"unique" `
	Event     EventPath    `json:"e" gorm:"index;char(64);"`
	Agent     DeviceString `json:"agt,omitempty"   gorm:"not null;type:varchar(100);index"`
}

func SubscriptionFromBytes

func SubscriptionFromBytes(b []byte) (Subscription, error)

func UnpackSubscription

func UnpackSubscription(b []byte) (Subscription, error)

func (Subscription) EncodeBytes

func (sub Subscription) EncodeBytes() ([]byte, error)

func (Subscription) GetAgent

func (sub Subscription) GetAgent() DeviceString

func (Subscription) GetEvent

func (sub Subscription) GetEvent() EventPath

func (Subscription) GetHash

func (sub Subscription) GetHash() ([]byte, error)

func (*Subscription) Key

func (sub *Subscription) Key() string

func (Subscription) MsgPack

func (sub Subscription) MsgPack() []byte

func (Subscription) ToJSON

func (sub Subscription) ToJSON() []byte

func (Subscription) ToString

func (subscription Subscription) ToString() string

type SuccessResponse

type SuccessResponse struct {
	Body ClientPayload
	Meta Meta
}

type SyncRequest

type SyncRequest struct {
	Interval ResponseInterval `json:"inter"`
	TopicIds string           `json:"topIds"`
}

* SYNC REQUEST PAYLOAD *

type SyncResponse

type SyncResponse struct {
	TimeFrame     ResponseInterval         `json:"time,omitempty"`
	Authorization []Authorization          `json:"auths,omitempty"`
	Presence      []Presence               `json:"presence,omitempty"`
	Topics        map[string]TopicResponse `json:"topics,omitempty"`
}

type Topic

type Topic struct {
	ID string `json:"id" gorm:"type:uuid;primaryKey;not null"`
	// Name            string        `json:"n,omitempty" binding:"required"`
	Ref             string    `json:"ref,omitempty" binding:"required" gorm:"uniqueIndex:idx_unique_subnet_ref;type:varchar(64);default:null"`
	Meta            string    `json:"meta,omitempty"`
	ParentTopicHash string    `json:"pTH,omitempty" gorm:"type:char(64)"`
	SubscriberCount uint64    `json:"sC,omitempty"`
	Account         DIDString `json:"acct,omitempty" binding:"required"  gorm:"not null;type:varchar(100)"`

	Agent DeviceString `json:"agt,omitempty" binding:"required"  gorm:"not null;type:varchar(100)"`
	//
	Public   *bool `json:"pub,omitempty" gorm:"default:false"`
	ReadOnly *bool `json:"rO,omitempty" gorm:"default:false"`

	// Derived
	Event EventPath `json:"e,omitempty" gorm:"index;varchar;"`
	Hash  string    `json:"h,omitempty" gorm:"type:char(64)"`
	// Signature   string    `json:"sig,omitempty" binding:"required"  gorm:"non null;"`
	// Broadcasted   bool      `json:"br,omitempty"  gorm:"default:false;"`
	Timestamp uint64 `json:"ts,omitempty" binding:"required"`
	Subnet    string `json:"snet" gorm:"uniqueIndex:idx_unique_subnet_ref;type:char(36);"`
}

func TopicFromBytes

func TopicFromBytes(b []byte) (Topic, error)

func UnpackTopic

func UnpackTopic(b []byte) (Topic, error)

func (*Topic) CanSend

func (p *Topic) CanSend(channel string, sender DIDString) bool

func (Topic) EncodeBytes

func (topic Topic) EncodeBytes() ([]byte, error)

func (Topic) GetAgent

func (topic Topic) GetAgent() DeviceString

func (Topic) GetEvent

func (topic Topic) GetEvent() EventPath

func (Topic) GetHash

func (topic Topic) GetHash() ([]byte, error)

func (*Topic) IsMember

func (p *Topic) IsMember(channel string, sender DIDString) bool

func (*Topic) Key

func (topic *Topic) Key() string

func (*Topic) MsgPack

func (topic *Topic) MsgPack() []byte

func (*Topic) ToJSON

func (topic *Topic) ToJSON() []byte

func (Topic) ToString

func (topic Topic) ToString() string

type TopicResponse

type TopicResponse struct {
	Updates  []Event `json:"updates,omitempty"`
	Joins    []Event `json:"joins,omitempty"`
	Leaves   []Event `json:"leaves,omitempty"`
	Messages []Event `json:"msg,omitempty"`
}

type Wallet

type Wallet struct {
	// Primary
	ID        string       `gorm:"primaryKey;type:uuid;not null" json:"id,omitempty"`
	Account   DIDString    `json:"acct"`
	Subnet    string       `json:"snet" gorm:"type:varchar(32);index;not null" msgpack:",noinline"`
	Name      string       `json:"n" gorm:"type:varchar(12);not null"`
	Symbol    string       `json:"sym" gorm:"type:varchar(8);not null"`
	Timestamp uint64       `json:"ts"`
	Agent     DeviceString `json:"agt,omitempty" binding:"required"  gorm:"not null;type:varchar(100)"`

	// Derived
	Event EventPath `json:"e,omitempty" gorm:"index;varchar;"`
	Hash  string    `json:"h,omitempty" gorm:"type:char(64)"`
}

func (*Wallet) BeforeCreate

func (d *Wallet) BeforeCreate(tx *gorm.DB) (err error)

func (Wallet) EncodeBytes

func (e Wallet) EncodeBytes() ([]byte, error)

func (Wallet) GetAgent

func (entity Wallet) GetAgent() DeviceString

func (Wallet) GetEvent

func (entity Wallet) GetEvent() EventPath

func (Wallet) GetHash

func (e Wallet) GetHash() ([]byte, error)

func (*Wallet) MsgPack

func (e *Wallet) MsgPack() []byte

func (*Wallet) ToJSON

func (e *Wallet) ToJSON() []byte

func (Wallet) ToString

func (e Wallet) ToString() string

type WalletBalance

type WalletBalance struct {
	// Primary
	ID      string       `gorm:"primaryKey;type:uuid;not null" json:"id,omitempty"`
	Account DIDString    `json:"acct"  gorm:"type:varchar(64);uniqueIndex:idx_wallet_acct;not null"`
	Wallet  string       `json:"wal"  gorm:"type:char(36);uniqueIndex:idx_wallet_acct;not null"`
	Balance big.Int      `json:"bal" gorm:"index;not null;default:0"`
	Agent   DeviceString `json:"agt,omitempty" binding:"required"  gorm:"not null;type:varchar(100)"`

	// Derived
	Event     EventPath `json:"e,omitempty" gorm:"index;not null;varchar;"`
	Timestamp uint64    `json:"ts"`
}

func (*WalletBalance) BeforeCreate

func (d *WalletBalance) BeforeCreate(tx *gorm.DB) (err error)

func (WalletBalance) EncodeBytes

func (e WalletBalance) EncodeBytes() ([]byte, error)

func (WalletBalance) GetAgent

func (entity WalletBalance) GetAgent() DeviceString

func (WalletBalance) GetEvent

func (entity WalletBalance) GetEvent() EventPath

func (WalletBalance) GetHash

func (e WalletBalance) GetHash() ([]byte, error)

func (*WalletBalance) MsgPack

func (e *WalletBalance) MsgPack() []byte

func (*WalletBalance) ToJSON

func (e *WalletBalance) ToJSON() []byte

func (WalletBalance) ToString

func (e WalletBalance) ToString() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL