Skip to content

Commit ec195f9

Browse files
committed
docs: Add /v3/signer/
1 parent 66ee0e1 commit ec195f9

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1616
- `get-stacks-block-info?` added
1717
- `get-tenure-info?` added
1818
- `get-block-info?` removed
19+
- Added `/v3/signer/` endpoint
1920

2021
## [2.5.0.0.5]
2122

docs/rpc-endpoints.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,3 +533,8 @@ highest sortition), `reward_cycle` identifies the reward cycle number of this
533533
tenure, `tip_block_id` identifies the highest-known block in this tenure, and
534534
`tip_height` identifies that block's height.
535535

536+
### GET /v3/signer/[Signer Pubkey]/[Reward Cycle]
537+
538+
Get number of blocks signed by signer during a given reward cycle
539+
540+
Returns a non-negative integer

docs/rpc/openapi.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,3 +675,33 @@ paths:
675675
schema:
676676
type: string
677677

678+
/v3/signer/{signer}/{cycle_number}:
679+
get:
680+
summary: Get number of blocks signed by signer during a given reward cycle
681+
tags:
682+
- Blocks
683+
- Signers
684+
operationId: get_signer
685+
description: Get number of blocks signed by signer during a given reward cycle
686+
parameters:
687+
- name: signer
688+
in: path
689+
required: true
690+
description: Hex-encoded compressed Secp256k1 public key of signer
691+
schema:
692+
type: string
693+
parameters:
694+
- name: cycle_number
695+
in: path
696+
required: true
697+
description: Reward cycle number
698+
schema:
699+
type: integer
700+
responses:
701+
200:
702+
description: Number of blocks signed
703+
content:
704+
text/plain:
705+
schema:
706+
type: integer
707+
example: 7

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3300,7 +3300,7 @@ impl NakamotoChainState {
33003300
chainstate_db: &Connection,
33013301
signer_pubkey: &Secp256k1PublicKey,
33023302
reward_cycle: u64,
3303-
) -> Result<Option<u64>, ChainstateError> {
3303+
) -> Result<u64, ChainstateError> {
33043304
let sql =
33053305
"SELECT blocks_signed FROM signer_stats WHERE public_key = ?1 AND reward_cycle = ?2";
33063306
let params = params![serde_json::to_string(&signer_pubkey).unwrap(), reward_cycle];
@@ -3316,6 +3316,7 @@ impl NakamotoChainState {
33163316
})
33173317
})
33183318
.optional()
3319+
.map(Option::unwrap_or_default) // It's fine to map `NONE` to `0`, because it's impossible to have `Some(0)`
33193320
.map_err(ChainstateError::from)
33203321
}
33213322

0 commit comments

Comments
 (0)