10 Commits

Author SHA1 Message Date
danda
c2fe657e04 perf: replace RwLock with ArcSwap
ArcSwap is lock-free and optimized for our use-case of lots of
concurrent reads and infrequent updates.

So it is pretty close to a shared-nothing architecture.

Some small changes were necessary, but its mostly a drop-in
replacement for RwLock.
2024-05-27 17:24:01 -07:00
danda
71cf752b41 feat: add neptune-core rpc connection watchdog
closes #1

Implements a background watchdog task that:
1. calls neptune-core /network rpc every N seconds (default: 10)
2. emits log message on any state change
3. sends detailed email alert to admin on any state change

Changes:
* AppState now has internal Arc<RwLock<AppStateInner>> to permit
  watchdog task to mutate the rpc_client field.
* adjust application to AppState changes (use locks)
* not_found functions no longer accept state arg
* move state initialization into AppState::init()
* add optional alert parameters: admin-email, smtp-*
* add neptune_rpc module with watchdog task
* add alert_email module
* simplify main()
* log warnings if alert parameters not set
* add chrono dep
* add lettre dep
2024-05-25 19:16:36 -07:00
danda
0c54b50b83 refactor: use wildcard paths, remove dup handlers
We use axum route wildcards to merge duplicate page routes and handlers
into a single route and handler.

This makes the routes simpler/cleaner as well as the handlers, as there
is now just one of each for each html page.

Previous:
   .route("/block/:selector", get(block_page))
   .route("/block/:selector/value", get(block_page_with_value))

New:
   .route("/block/*selector", get(block_page))

This is achieved by replacing PathBlockSelector with
BlockSelectorExtended which wraps BlockSelector to provide parsing for
height_or_digest/value.  (which is needed for javascript-free input
form)

Changes:
 * merge dup handlers for each of block, block_digest, block_info
 * merge routes for same
 * add BlockSelectorExtended and HeightOrDigest
 * remove PathBlockSelector
2024-05-22 17:18:51 -07:00
danda
29834dbe50 feat: get rid of all javascript
implements a generic solution to redirect query strings generated by
forms to path based URIs that can be handled by existing routes.

This eliminates the need for javascript that was doing the equivalent
client-side.
2024-05-22 17:18:51 -07:00
danda
df14092d61 feat: make site name configurable
Changes:
 + add Config::site_name, which defaults to "Neptune Explorer"
 + remove HeaderHtml::site_name
 + use Config::site_name in the html templates
2024-05-22 17:18:51 -07:00
danda
faf303bbdd feat: integrate team feedback
Changes:
 + present not-found page for unhandled uri paths, eg /stuff
 + display the tip-height on front page
 + add favicon and neptune logo to front page
 + use ServerDir instead of ServeFile for /image and /css
 + add help tooltips for fields on front page
 + use monospace font for digests
2024-05-22 17:18:51 -07:00
danda
d7d1778fea fix: add missing files 2024-05-22 17:18:51 -07:00
danda
ac27329bda chore: update to neptune-core tip
adapts to some changes in neptune-core.

BlockInfo and BlockSelector location changed.
2024-05-22 17:18:50 -07:00
danda
0f9cbdf0b4 feat: pico css styling and not-found page.
Changes:

 1. integrates pico minimal responsive css framework for light/dark
    themes and overall better looks.

 2. adds a not-found page for bad url queries.

 3. catches axum/serde deserialization errors of user input and routes
    them to the not-found page with a helpful hint (parse error msg)
2024-05-22 17:18:50 -07:00
danda
7fa11f3ec2 refactor: break main.rs into separate files 2024-05-22 17:18:50 -07:00