entities

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: LGPL-2.1 Imports: 31 Imported by: 0

Documentation

Index

Constants

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

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_subnet;index:idx_authorization_states_agent"`
	Meta          string                            `json:"meta,omitempty"`
	Account       DIDString                         `json:"acct" gorm:"varchar(40);"`
	Grantor       DIDString                         `json:"gr" gorm:"index"`
	Priviledge    *constants.AuthorizationPrivilege `json:"privi"  gorm:""`
	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:"uniqueIndex:idx_agent_account_subnet;char(36)"`
	BlockNumber   uint64                            `json:"blk"`
	Cycle         uint64                            `json:"cy"`
	Epoch         uint64                            `json:"ep"`
}

func UnpackAuthorization added in v1.2.0

func UnpackAuthorization(b []byte) (Authorization, error)

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 Channel added in v1.2.0

type Channel struct {
	// Messages is a channel of messages received from other peers in the chat channel
	Messages chan PubSubMessage

	Ctx context.Context

	Topic *pubsub.Topic

	ChannelName string
	ID          peer.ID
	Wallet      string
	// contains filtered or unexported fields
}
var AuthorizationPubSub Channel
var MessagePubSub Channel
var SubnetPubSub Channel
var SubscriptionPubSub Channel
var TopicPubSub Channel
var WalletPubSub Channel

func JoinChannel added in v1.2.0

func JoinChannel(ctx context.Context, ps *pubsub.PubSub, selfID peer.ID, walletAddress string, channelName string, channelBufferSize uint) (*Channel, error)

func (*Channel) ListPeers added in v1.2.0

func (cr *Channel) ListPeers() []peer.ID

func (*Channel) Publish added in v1.2.0

func (cr *Channel) Publish(m PubSubMessage) error

Publish sends a message to the pubsub topic.

type ClaimData added in v1.2.0

type ClaimData struct {
	// Cycle uint64
	// Signature [32]byte
	// Commitment []byte
	// PubKeys []*btcec.PublicKey
	// SubnetRewardCount []SubnetCount
	Validator  []byte
	ClaimData  []SubnetCount
	Cycle      *big.Int
	Index      *big.Int
	Signers    []schnorr.Point
	Commitment []byte
	Signature  []byte
	TotalCost  *big.Int
}

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"`
	ChainId      configs.ChainId    `json:"chId"`
	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 uint64          `json:"ts"`
	EventType uint16          `json:"ty"`
	Nonce     uint64          `json:"nonce"`
	Account   DIDString       `json:"acct,omitempty"` // optional public key of sender
	ChainId   configs.ChainId `json:"chId"`           // optional public key of sender

	Validator string `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 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"`
	OperatorAddress 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

func StringToDeviceString added in v1.2.0

func StringToDeviceString(str string) DeviceString

type EntityModel added in v1.2.0

type EntityModel string
const (
	AuthModel         EntityModel = "auth"
	TopicModel        EntityModel = "top"
	SubscriptionModel EntityModel = "sub"
	MessageModel      EntityModel = "msg"
	SubnetModel       EntityModel = "snet"
	WalletModel       EntityModel = "wal"
)

func GetModel added in v1.2.0

func GetModel(ent any) EntityModel

type EntityPath added in v1.2.0

type EntityPath struct {
	Model     EntityModel     `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 EntityPathFromString added in v1.2.0

func EntityPathFromString(path string) *EntityPath

func NewEntityPath added in v1.2.0

func NewEntityPath(validator PublicKeyString, model EntityModel, hash string) *EntityPath

func UnpackEntityPath added in v1.2.0

func UnpackEntityPath(b []byte) (*EntityPath, error)

func (EntityPath) GormDataType added in v1.2.0

func (eP EntityPath) GormDataType() string

func (EntityPath) GormValue added in v1.2.0

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

func (*EntityPath) MsgPack added in v1.2.0

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

func (*EntityPath) Scan added in v1.2.0

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

func (*EntityPath) ToString added in v1.2.0

func (e *EntityPath) ToString() string

func (*EntityPath) Value added in v1.2.0

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

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);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:"type:char(64)"`
	Signature   string          `json:"sig"`
	Broadcasted bool            `json:"br"`
	BlockNumber uint64          `json:"blk"`
	Cycle       uint64          `json:"cy"`
	Epoch       uint64          `json:"ep"`
	IsValid     bool            `json:"isVal" gorm:"default:false"`
	Synced      bool            `json:"sync" gorm:"default:false"`
	Validator   PublicKeyString `json:"val"`
	Subnet      string          `json:"snet"`

	Total int `json:"total"`
}

func EventFromJSON

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

func GetEventEntityFromModel added in v1.2.0

func GetEventEntityFromModel(eventType EntityModel) *Event

func UnpackEvent

func UnpackEvent(b []byte, model EntityModel) (*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) GetDataModelType added in v1.2.0

func (e *Event) GetDataModelType() EntityModel

func (Event) GetHash

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

func (*Event) GetPath added in v1.2.0

func (e *Event) GetPath() *EventPath

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
	ValidateData(config *configs.MainConfiguration) (authState any, err error)
}

type EventPath

type EventPath struct {
	EntityPath
}

func EventPathFromString

func EventPathFromString(path string) *EventPath

func NewEventPath

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

func UnpackEventPath added in v1.2.0

func UnpackEventPath(b []byte) (*EventPath, error)

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"`
	Topic  string    `json:"top,omitempty"`
	Sender DIDString `json:"s"`
	// OwnerAddress  string              `json:"oA"`
	Receiver DIDString          `json:"r,omitempty"`
	Data     string             `json:"d"`
	DataType constants.DataType `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)"`
	Nonce uint64       `json:"nonce,omitempty" binding:"required"`

	/// 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"`
	BlockNumber uint64 `json:"blk"`
	Cycle       uint64 `json:"cy"`
	Epoch       uint64 `json:"ep"`
}

func MessageFromBytes

func MessageFromBytes(b []byte) *Message

func MessageFromString

func MessageFromString(msg string) *Message

func UnpackMessage added in v1.2.0

func UnpackMessage(b []byte) (Message, error)

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 ProofData added in v1.2.0

type ProofData struct {
	DataHash   json.RawMessage `json:"bH"`
	ChainId    configs.ChainId `json:"chId"`
	Cycle      uint64          `json:"cyc"`
	Index      int             `json:"idx"`
	Validator  json.RawMessage `json:"val"`
	Signature  json.RawMessage `json:"sig"`
	Signers    [][]byte        `json:"signers"`
	Commitment json.RawMessage `json:"com"`
	TotalCost  json.RawMessage `json:"mCo"`
}

func UnpackProofData added in v1.2.0

func UnpackProofData(b []byte) (*ProofData, error)

func (*ProofData) EncodeBytes added in v1.2.0

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

func (*ProofData) GetHash added in v1.2.0

func (rb *ProofData) GetHash() ([32]byte, error)

func (*ProofData) MsgPack added in v1.2.0

func (sr *ProofData) MsgPack() []byte

type PubKeyType

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

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

func (PublicKeyString) Bytes added in v1.2.0

func (s PublicKeyString) Bytes() []byte

type RegisterationData added in v1.2.0

type RegisterationData struct {
	ChainId   configs.ChainId `json:"cId"`
	Timestamp uint64          `json:"ts"`
	PubKeyEDD json.RawMessage `json:"pubEDD"`
}

func (RegisterationData) EncodeBytes added in v1.2.0

func (regData RegisterationData) EncodeBytes() ([]byte, error)

func (*RegisterationData) GetHash added in v1.2.0

func (regData *RegisterationData) GetHash() []byte

func (*RegisterationData) Sign added in v1.2.0

func (regData *RegisterationData) Sign(privkBytes []byte) ([]byte, schnorr.EthAddress, error)

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 RewardBatch added in v1.2.0

type RewardBatch struct {
	Id           string          `json:"id"`
	Index        int             `json:"idx"`
	Data         []SubnetCount   `json:"d"`
	DataBoundary [2]SubnetCount  `json:"dBound"`
	DataHash     json.RawMessage `json:"dH"`
	ChainId      configs.ChainId `json:"pre"`
	Closed       bool            `json:"cl"`
	Cycle        uint64          `json:"nh"`
	MessageCost  json.RawMessage `json:"cost"`
	TotalValue   json.RawMessage `json:"tv"`
	// Proofs       Proof           `json:"proof"`
	Timestamp uint64          `json:"ts"`
	Validator json.RawMessage `json:"val"`
	// contains filtered or unexported fields
}

RewardBatch

func NewRewardBatch added in v1.2.0

func NewRewardBatch(config *configs.MainConfiguration, cycle uint64, index int, cycleMessageCost *big.Int, cycleSize int, validator []byte) *RewardBatch

func RewardBatchFromBytes added in v1.2.0

func RewardBatchFromBytes(b []byte) (*RewardBatch, error)

func UnpackRewardBatch added in v1.2.0

func UnpackRewardBatch(b []byte) (*RewardBatch, error)

func (*RewardBatch) Append added in v1.2.0

func (msg *RewardBatch) Append(subnetCount SubnetCount)

func (*RewardBatch) Clear added in v1.2.0

func (msg *RewardBatch) Clear()

func (*RewardBatch) EncodeBytes added in v1.2.0

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

func (*RewardBatch) GetHash added in v1.2.0

func (rb *RewardBatch) GetHash(chainId configs.ChainId) ([32]byte, error)

func (*RewardBatch) GetProofData added in v1.2.0

func (msg *RewardBatch) GetProofData(chainId configs.ChainId) *ProofData

func (*RewardBatch) MsgPack added in v1.2.0

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

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 SignatureRequestData added in v1.2.0

type SignatureRequestData struct {
	ProofHash json.RawMessage `json:"pH"`
	Challenge json.RawMessage `json:"chal"`
}

func UnpackSignatureRequestData added in v1.2.0

func UnpackSignatureRequestData(b []byte) (*SignatureRequestData, error)

func (*SignatureRequestData) MsgPack added in v1.2.0

func (sr *SignatureRequestData) MsgPack() []byte

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" binding:"required"  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);default:did"`
	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:"_"`

	// CreateTopicPrivilege   *constants.AuthorizationPrivilege `json:"cTopPriv"` //
	DefaultAuthPrivilege *constants.AuthorizationPrivilege `json:"dAuthPriv"` // privilege for external users who joins the subnet. 0 indicates people cant join

	// Derived
	Event       EventPath `json:"e,omitempty" gorm:"index;varchar;"`
	Hash        string    `json:"h,omitempty" gorm:"type:char(64)"`
	BlockNumber uint64    `json:"blk"`
	Cycle       uint64    `json:"cy"`
	Epoch       uint64    `json:"ep"`
}

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 SubnetCount added in v1.2.0

type SubnetCount struct {
	Subnet     string          `json:"sNet"`
	EventCount uint64          `json:"eC"`
	Cost       json.RawMessage `json:"cost"`
}

func (*SubnetCount) EncodeBytes added in v1.2.0

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

type Subscription

type Subscription struct {
	ID         string    `gorm:"primaryKey;type:char(36);not null"  json:"id,omitempty"`
	Topic      string    `json:"top" binding:"required"  gorm:"not null;uniqueIndex:idx_sub_topic;type:char(36);index"`
	Ref        string    `json:"ref" gorm:"uniqueIndex:idx_ref_subnet;type:varchar(100);default:null"`
	Meta       string    `json:"meta"  gorm:"type:varchar(100);"`
	Subnet     string    `json:"snet"  binding:"required" gorm:"not null;uniqueIndex:idx_ref_subnet;type:varchar(36)"`
	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.SubscriptionStatus `json:"st"  gorm:"not null;type:smallint;default:2"`
	Role   *constants.SubscriberRole     `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" binding:"required"  gorm:"not null;type:varchar(100);index"`
	BlockNumber uint64       `json:"blk"`
	Cycle       uint64       `json:"cy"`
	Epoch       uint64       `json:"ep"`
}

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"`

	DefaultSubscriberRole *constants.SubscriberRole `json:"dSubRol,omitempty"`

	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);"`
	// Subnet string `json:"snet" gorm:"index;varchar(36)"`
	BlockNumber uint64 `json:"blk"`
	Cycle       uint64 `json:"cy"`
	Epoch       uint64 `json:"ep"`
}

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)"`
	BlockNumber uint64    `json:"blk"`
	Cycle       uint64    `json:"cy"`
	Epoch       uint64    `json:"ep"`
}

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"`
	BlockNumber uint64    `json:"blk"`
	Cycle       uint64    `json:"cy"`
	Epoch       uint64    `json:"ep"`
}

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