agent

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: GPL-2.0 Imports: 14 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 string) (a *Backend, err error)

func (*Backend) ClearEvents

func (b *Backend) ClearEvents(c context.T) (result string, err error)

func (*Backend) CountEvents

func (b *Backend) CountEvents(c context.T, 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) DeleteEvent

func (b *Backend) DeleteEvent(c context.T, 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(c context.T, filter *Filter) ([]Event, error)

func (*Backend) QueryEvents

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

func (*Backend) SaveCandidEvent

func (b *Backend) SaveCandidEvent(event Event) (result string, err error)

func (*Backend) SaveEvent

func (b *Backend) SaveEvent(c context.T, 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