func IsAccessAllowed
IsAccessAllowed checks if an address has a current (non-expired) access rule. rules is an avl.Tree keyed by allowed address holding AccessRule values.
Package nightsky holds the shared types and single-telescope logic for the GnoNightSky telescope network.
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.
IsAccessAllowed checks if an address has a current (non-expired) access rule. rules is an avl.Tree keyed by allowed address holding AccessRule values.
ValidateCommand validates a telescope command
NewCaptureFeed creates a feed that keeps at most max entries.
1func NewTelescopeConfig(name, model string, lat, lon float64, owner, realmPath string) TelescopeConfigNewTelescopeConfig creates a new telescope configuration
NewTelescopeRealm creates a new telescope realm instance
AccessRule defines who can access a telescope
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.
Add inserts a capture as the newest entry and trims the oldest if the feed is over capacity.
IterateNewest calls cb for each capture from newest to oldest. Return true from cb to stop early.
Latest returns the most recent capture, if any.
Len returns the number of stored captures.
RemoveAt removes the index-th newest capture (0 = most recent). It reports whether a capture was removed. Used for moderation of individual entries.
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}CaptureResult represents the result of an image capture
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}TelescopeCommand represents a command sent to a telescope
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}TelescopeConfig contains the settings and configuration for a telescope
UpdateStatus updates the telescope status
TelescopeRealm manages a single telescope's state and operations
ClearCommandQueue clears all pending commands (emergency stop)
GetAccessRuleCount returns the number of access rules
GetCaptureCount returns the number of stored captures
GetCommandCount returns the number of pending commands
GetNextCommand returns the next command in the queue (for telescope controller)
GrantAccess allows the owner to grant access to another user. Re-granting to an existing address overwrites the previous rule.
1func (r *TelescopeRealm) RecordCapture(caller, imageURL string, targetRA, targetDec float64, exposure int, capturedBy string)RecordCapture allows the owner to record a capture result
RenderNightsky generates the markdown output for the telescope realm. Call this from your realm's Render(path string) string function.
RevokeAccess removes access for a specific address
1func (r *TelescopeRealm) SubmitCommand(caller, commandType string, targetRA, targetDec float64, exposure int)SubmitCommand allows authorized users to submit telescope commands
UpdateStatus allows the owner to update telescope status