Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v1 source pure

Package nightsky holds the shared types and single-telescope logic for the GnoNightSky telescope network.

Overview

Package nightsky holds the shared types and single-telescope logic for the GnoNightSky telescope network.

Note on panics: although this lives under p/, it is application-specific logic for the NightSky realms rather than a general-purpose reusable library. It deliberately panics on invalid input / failed preconditions (the assert-like style described in effective-gno) so the wrapping realms don't have to re-check every error. Callers that want softer handling should validate before calling.

Functions 5

func IsAccessAllowed

1func IsAccessAllowed(address string, rules *avl.Tree) bool
source

IsAccessAllowed checks if an address has a current (non-expired) access rule. rules is an avl.Tree keyed by allowed address holding AccessRule values.

func ValidateCommand

1func ValidateCommand(cmd TelescopeCommand, config TelescopeConfig)
source

ValidateCommand validates a telescope command

func NewCaptureFeed

1func NewCaptureFeed(max int) *CaptureFeed
source

NewCaptureFeed creates a feed that keeps at most max entries.

func NewTelescopeConfig

1func NewTelescopeConfig(name, model string, lat, lon float64, owner, realmPath string) TelescopeConfig
source

NewTelescopeConfig creates a new telescope configuration

func NewTelescopeRealm

1func NewTelescopeRealm(config *TelescopeConfig) *TelescopeRealm
source

NewTelescopeRealm creates a new telescope realm instance

Types 6

type AccessRule

struct
1type AccessRule struct {
2	AllowedAddress string    // Gno address allowed to access
3	GrantedBy      string    // Who granted access
4	GrantedAt      time.Time // When access was granted
5	ExpiresAt      time.Time // When access expires (zero time = never)
6}
source

AccessRule defines who can access a telescope

type CaptureFeed

struct
1type CaptureFeed struct {
2	tree *avl.Tree
3	seq  int
4	max  int
5}
source

CaptureFeed is a bounded, newest-first collection of CaptureResult values backed by an avl.Tree. It is used for both a single telescope's history and the network-wide recent feed.

Entries are keyed by a zero-padded, monotonically increasing sequence so the tree iterates in insertion order. Newest-first reads use ReverseIterate, and trimming removes the lowest key (the oldest entry). This avoids the O(n) slice-prepend the previous implementation paid on every insert, and only loads the search path on access instead of the whole collection.

Methods on CaptureFeed

func Add

method on CaptureFeed
1func (f *CaptureFeed) Add(c CaptureResult)
source

Add inserts a capture as the newest entry and trims the oldest if the feed is over capacity.

func IterateNewest

method on CaptureFeed
1func (f *CaptureFeed) IterateNewest(cb func(c CaptureResult) bool)
source

IterateNewest calls cb for each capture from newest to oldest. Return true from cb to stop early.

func Latest

method on CaptureFeed
1func (f *CaptureFeed) Latest() (CaptureResult, bool)
source

Latest returns the most recent capture, if any.

func Len

method on CaptureFeed
1func (f *CaptureFeed) Len() int
source

Len returns the number of stored captures.

func RemoveAt

method on CaptureFeed
1func (f *CaptureFeed) RemoveAt(index int) bool
source

RemoveAt removes the index-th newest capture (0 = most recent). It reports whether a capture was removed. Used for moderation of individual entries.

type CaptureResult

struct
1type CaptureResult struct {
2	ImageURL    string    // URL to the captured image (e.g., Imgur)
3	TargetRA    float64   // Right Ascension of target
4	TargetDec   float64   // Declination of target
5	Exposure    int       // Exposure time in seconds
6	CapturedBy  string    // Who captured the image
7	CapturedAt  time.Time // When the image was captured
8	TelescopeID string    // Which telescope captured it
9}
source

CaptureResult represents the result of an image capture

type TelescopeCommand

struct
1type TelescopeCommand struct {
2	CommandType string    // "capture" or "stop"
3	TargetRA    float64   // Right Ascension (for pointing/tracking)
4	TargetDec   float64   // Declination (for pointing/tracking)
5	Exposure    int       // Exposure time in seconds (for capture)
6	RequestedBy string    // Who requested the command
7	RequestedAt time.Time // When the command was requested
8}
source

TelescopeCommand represents a command sent to a telescope

type TelescopeConfig

struct
 1type TelescopeConfig struct {
 2	Name       string    // Name of the telescope
 3	Model      string    // Telescope model (e.g., "Seestar S50")
 4	Latitude   float64   // Geographic location
 5	Longitude  float64   // Geographic location
 6	Owner      string    // Owner's gno address
 7	RealmPath  string    // Path to the telescope's realm (e.g., "/r/username/telescope")
 8	Status     string    // Current status: "online", "offline", "busy", "error"
 9	LastUpdate time.Time // Last status update
10}
source

TelescopeConfig contains the settings and configuration for a telescope

Methods on TelescopeConfig

func UpdateStatus

method on TelescopeConfig
1func (t *TelescopeConfig) UpdateStatus(status string)
source

UpdateStatus updates the telescope status

type TelescopeRealm

struct
1type TelescopeRealm struct {
2	Config       *TelescopeConfig
3	AccessRules  *avl.Tree // key: allowed address -> AccessRule
4	CommandQueue []TelescopeCommand
5	Captures     *CaptureFeed
6	OwnerAddress string
7}
source

TelescopeRealm manages a single telescope's state and operations

Methods on TelescopeRealm

func ClearCommandQueue

method on TelescopeRealm
1func (r *TelescopeRealm) ClearCommandQueue(caller string)
source

ClearCommandQueue clears all pending commands (emergency stop)

func GetAccessRuleCount

method on TelescopeRealm
1func (r *TelescopeRealm) GetAccessRuleCount() int
source

GetAccessRuleCount returns the number of access rules

func GetCaptureCount

method on TelescopeRealm
1func (r *TelescopeRealm) GetCaptureCount() int
source

GetCaptureCount returns the number of stored captures

func GetCommandCount

method on TelescopeRealm
1func (r *TelescopeRealm) GetCommandCount() int
source

GetCommandCount returns the number of pending commands

func GetNextCommand

method on TelescopeRealm
1func (r *TelescopeRealm) GetNextCommand(caller string) TelescopeCommand
source

GetNextCommand returns the next command in the queue (for telescope controller)

func GrantAccess

method on TelescopeRealm
1func (r *TelescopeRealm) GrantAccess(caller, address string, durationDays int)
source

GrantAccess allows the owner to grant access to another user. Re-granting to an existing address overwrites the previous rule.

func RecordCapture

method on TelescopeRealm
1func (r *TelescopeRealm) RecordCapture(caller, imageURL string, targetRA, targetDec float64, exposure int, capturedBy string)
source

RecordCapture allows the owner to record a capture result

func RenderNightsky

method on TelescopeRealm
1func (r *TelescopeRealm) RenderNightsky(path string) string
source

RenderNightsky generates the markdown output for the telescope realm. Call this from your realm's Render(path string) string function.

func RevokeAccess

method on TelescopeRealm
1func (r *TelescopeRealm) RevokeAccess(caller, address string)
source

RevokeAccess removes access for a specific address

func SubmitCommand

method on TelescopeRealm
1func (r *TelescopeRealm) SubmitCommand(caller, commandType string, targetRA, targetDec float64, exposure int)
source

SubmitCommand allows authorized users to submit telescope commands

func UpdateStatus

method on TelescopeRealm
1func (r *TelescopeRealm) UpdateStatus(caller string, status string)
source

UpdateStatus allows the owner to update telescope status

Imports 6

Source Files 5