Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions doc/smpv.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ If you are also running the HTTP server, the SMPV endpoints are documented separ
./spvnode -x -u 127.0.0.1:8080 scan
```

To run spvnode with debug logging, continuous mode, SMPV enabled, HTTP REST API, and checkpoints:

```bash
./spvnode -d -c -x -u 127.0.0.1:8080 -p -b scan
```

**Note**: The `-b` flag is **recommended** but not strictly required. Without it, `spvnode` will automatically transition to full block sync when reaching the chain tip. See `tools.md` for more details on all available flags.

```bash
./spvnode -d -c -x -u 127.0.0.1:8080 -p scan
```
This will sync headers first (fast), then auto-transition to full block sync at the tip.

## API Reference

### Client Management
Expand Down
17 changes: 17 additions & 0 deletions include/dogecoin/smpv.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <dogecoin/dogecoin.h>
#include <dogecoin/chainparams.h>
#include <dogecoin/tx.h>
#include <dogecoin/uthash.h>

LIBDOGECOIN_BEGIN_DECL

Expand Down Expand Up @@ -69,6 +70,13 @@ typedef struct {
dogecoin_bool is_active; /* Whether watcher is active */
} dogecoin_smpv_watcher;

/* Hash table entry for txid lookup */
typedef struct smpv_tx_lookup_ {
char txid[65]; /* key: hex txid (64 chars + NUL) */
uint32_t index; /* index into mempool_txs array */
UT_hash_handle hh;
} smpv_tx_lookup;

/* SMPV client structure */
typedef struct {
const dogecoin_chainparams* chain_params;
Expand All @@ -79,6 +87,9 @@ typedef struct {
dogecoin_bool is_running;
uint64_t last_update_time;

/* txid lookup index */
smpv_tx_lookup* tx_lookup;

/* lightweight running totals (not exposed via new APIs) */
uint64_t total_bytes;
uint32_t confirmed_count;
Expand Down Expand Up @@ -168,6 +179,12 @@ LIBDOGECOIN_API void dogecoin_smpv_update_tx_status(
uint32_t block_height
);

/* Recalculate all confirmation counts after a new tip */
LIBDOGECOIN_API void dogecoin_smpv_tip_update(
dogecoin_smpv_client* client,
uint32_t tip_height
);

/* Get mempool statistics */
LIBDOGECOIN_API void dogecoin_smpv_get_stats(
const dogecoin_smpv_client* client,
Expand Down
3 changes: 2 additions & 1 deletion src/rest.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,10 @@ void dogecoin_http_request_cb(struct evhttp_request *req, void *arg) {
total_bytes = smpv->total_bytes;
last_seen_ts = smpv->last_seen_ts;

// sum per-tx script classifications
// sum per-tx script classifications for current mempool (unconfirmed only)
for (uint32_t i = 0; i < smpv->mempool_tx_count; i++) {
const dogecoin_smpv_tx* t = &smpv->mempool_txs[i];
if (t->is_confirmed) continue;
p2pk += t->pubkey_out;
p2pkh += t->p2pkh_out;
p2sh += t->p2sh_out;
Expand Down
Loading
Loading