agent

package
v1.2.17 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CandidToEvent

func CandidToEvent(e *Event) *event.T

Types

type Backend

type Backend struct {
	Ctx        context.T
	Agent      *agent_go.Agent
	CanisterID principal.Principal
}

func New

func New(c context.T, cid, canAddr, secKey string) (a *Backend, err error)

func (*Backend) AddUser

func (b *Backend) AddUser(pubKey string, perm bool) (err error)

func (*Backend) ClearCandidEvents

func (b *Backend) ClearCandidEvents() (err error)

func (*Backend) ClearEvents

func (b *Backend) ClearEvents() (err error)

func (*Backend) CountCandidEvent

func (b *Backend) CountCandidEvent(filter *Filter) (int, error)

func (*Backend) CountEvents

func (b *Backend) CountEvents(f *filter.T) (count int, err error)

CountEvents counts how many events match the filter in the IC. todo: use the proper count events API call in the canister

func (*Backend) DeleteCandidEvent

func (b *Backend) DeleteCandidEvent(event Event) (err error)

func (*Backend) DeleteEvent

func (b *Backend) DeleteEvent(ev *event.T) (err error)

DeleteEvent deletes an event matching the given event. todo: not yet implemented, but there is already a backend function for this

func (*Backend) GetCandidEvent

func (b *Backend) GetCandidEvent(filter *Filter) ([]Event, error)

func (*Backend) GetPermission

func (b *Backend) GetPermission() (result string, err error)

func (*Backend) QueryEvents

func (b *Backend) QueryEvents(f *filter.T) (ch event.C, err error)

func (*Backend) RemoveUser

func (b *Backend) RemoveUser(pubKey string) (err error)

func (*Backend) SaveCandidEvent

func (b *Backend) SaveCandidEvent(event Event) (err error)

func (*Backend) SaveEvent

func (b *Backend) SaveEvent(e *event.T) (err error)

type Event

type Event struct {
	ID        string     `ic:"id"`
	Pubkey    string     `ic:"pubkey"`
	CreatedAt int64      `ic:"created_at"`
	Kind      uint16     `ic:"kind"`
	Tags      [][]string `ic:"tags"`
	Content   string     `ic:"content"`
	Sig       string     `ic:"sig"`
}

func EventToCandid

func EventToCandid(e *event.T) Event

type Filter

type Filter struct {
	IDs     []string       `ic:"ids"`
	Kinds   []uint16       `ic:"kinds"`
	Authors []string       `ic:"authors"`
	Tags    []KeyValuePair `ic:"tags"`
	Since   int64          `ic:"since"`
	Until   int64          `ic:"until"`
	Limit   int64          `ic:"limit"`
	Search  string         `ic:"search"`
}

func FilterToCandid

func FilterToCandid(f *filter.T) (result *Filter)

type KeyValuePair

type KeyValuePair struct {
	Key   string   `ic:"key"`
	Value []string `ic:"value"`
}

func TagMapToKV

func TagMapToKV(t filter.TagMap) (keys []KeyValuePair)

Jump to

Keyboard shortcuts

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