aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/guides/federation/getting-started.md3
-rw-r--r--docs/guides/federation/running-a-node.md12
-rw-r--r--docs/openapi.yaml10
-rw-r--r--src/api/events.rs8
-rw-r--r--src/federation/held.rs5
5 files changed, 27 insertions, 11 deletions
diff --git a/docs/guides/federation/getting-started.md b/docs/guides/federation/getting-started.md
index 5d46192..ce2b614 100644
--- a/docs/guides/federation/getting-started.md
+++ b/docs/guides/federation/getting-started.md
@@ -89,7 +89,8 @@ continuum --store-root root --store-party tv --store-file store.json \
--state-file state.json --document-file document --node-key-file node.key \
--htpasswd htpasswd --mycelium-enable
curl -s -u tv:secret localhost:3000/events
-# {"checkpoint":"6d1e…","heads":["6d1e…"],"store":"6d1e…","taken":0}
+# {"checkpoint":"6d1e…","heads":["6d1e…"],"party":"tv","store":"6d1e…","taken":0,
+# "votesByItself":false}
```
lass's node joins it by its ID, through tv's node, one of whose addresses it is given
diff --git a/docs/guides/federation/running-a-node.md b/docs/guides/federation/running-a-node.md
index d903b2d..af16594 100644
--- a/docs/guides/federation/running-a-node.md
+++ b/docs/guides/federation/running-a-node.md
@@ -62,12 +62,12 @@ alone, so that a party listing many nodes can't be all of a node's neighbours.
fork's root. A token is taken by the node that issued it only. Let in those who act
for the node, and give a party without nodes of its own a user to put its events.
* **The events** (`docs/openapi.yaml`, Events): `GET /events` (the store's ID, its
- checkpoint, its heads, how many events it took), `POST /events` (an event, whoever
- signed it), `GET /events/{id}`, `GET /events/counts` (what counts),
- `GET /events/refused` (what the store refused, and why), `POST /events/fork` (what the
- node finds of a fork's root); and its operator's: `POST /admin/events/drop`,
- `/admin/events/allow`, `/admin/events/vote`, `/admin/events/fork`. Each answers
- `404` while the node holds no store.
+ checkpoint, its heads, how many events it took, the node's party, and whether it votes
+ for it by itself), `POST /events` (an event, whoever signed it), `GET /events/{id}`,
+ `GET /events/counts` (what counts), `GET /events/refused` (what the store refused, and
+ why), `POST /events/fork` (what the node finds of a fork's root); and its operator's:
+ `POST /admin/events/drop`, `/admin/events/allow`, `/admin/events/vote`,
+ `/admin/events/fork`. Each answers `404` while the node holds no store.
* **The store API** (`/store`) reads the document, where events are bytes at
`_continuum/events/<ID>`; what counts is read at `GET /events/counts`. A write through
it is refused (`403`): the document takes events and each node's own protocol data
diff --git a/docs/openapi.yaml b/docs/openapi.yaml
index 789ee6c..5cffccf 100644
--- a/docs/openapi.yaml
+++ b/docs/openapi.yaml
@@ -1418,7 +1418,9 @@ paths:
description: |
The store's ID (its root's), its checkpoint's ID, its heads (what a new event
builds on) and how many events it took after its checkpoint, as this node reads
- it now.
+ it now; the party this node is of (`party`, `--store-party`), and whether it
+ votes for it by itself (`votesByItself`), and so casts votes by hand
+ (`POST /admin/events/vote`).
responses:
'200':
description: The store.
@@ -1426,7 +1428,7 @@ paths:
application/json:
schema:
type: object
- required: [store, checkpoint, heads, taken]
+ required: [store, checkpoint, heads, taken, party, votesByItself]
properties:
store:
type: string
@@ -1438,6 +1440,10 @@ paths:
type: string
taken:
type: integer
+ party:
+ type: [string, 'null']
+ votesByItself:
+ type: boolean
'404':
$ref: '#/components/responses/Error'
post:
diff --git a/src/api/events.rs b/src/api/events.rs
index b388acc..3017c25 100644
--- a/src/api/events.rs
+++ b/src/api/events.rs
@@ -77,15 +77,19 @@ fn why(refusal: &Refusal) -> String {
}
}
-/// `GET /events`: the store's ID, its checkpoint's, its heads, and how many events it
-/// took after its checkpoint.
+/// `GET /events`: the store's ID, its checkpoint's, its heads, how many events it took
+/// after its checkpoint, the node's party, and whether the node votes for it by itself.
async fn summary(State(state): State<AppState>) -> Response {
+ let party = state.holding.party().map(str::to_owned);
+ let votes = state.holding.votes_by_itself();
with_store(&state, |store| {
json!({
"store": store.id().to_string(),
"checkpoint": Id::of(store.checkpoint()).to_string(),
"heads": ids(store.heads()),
"taken": store.taken().len(),
+ "party": party,
+ "votesByItself": votes,
})
})
}
diff --git a/src/federation/held.rs b/src/federation/held.rs
index 985ff45..3ca74a9 100644
--- a/src/federation/held.rs
+++ b/src/federation/held.rs
@@ -783,6 +783,11 @@ impl Holding {
self.party.as_deref()
}
+ /// Whether the node votes for its party by itself (`--store-vote-key`).
+ pub(crate) fn votes_by_itself(&self) -> bool {
+ self.voter.is_some() && self.party.is_some()
+ }
+
/// Itself, the node keeping some of its neighbours among the members of `parties`,
/// with those of its own (`--store-neighbour-parties`).
pub(crate) fn near(self, parties: Vec<String>) -> Self {