Commitment
solana.rpc.commitment
Commitment options.
Solana nodes choose which bank state to query based on a commitment requirement set by the client.
In descending order of commitment (most finalized to least finalized), clients may specify:
Commitment
Enumeration of commitment levels for RPC requests.
Members
Source code in src/solana/rpc/commitment.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
CONFIRMED = 'confirmed'
class-attribute
instance-attribute
The node will query the most recent block that has been voted on by supermajority of the cluster.
- It incorporates votes from gossip and replay.
- It does not count votes on descendants of a block, only direct votes on that block.
- This confirmation level also upholds "optimistic confirmation" guarantees in release 1.3 and onwards.
FINALIZED = 'finalized'
class-attribute
instance-attribute
The node will query the most recent block confirmed by supermajority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.
PROCESSED = 'processed'
class-attribute
instance-attribute
The node will query its most recent block. Note that the block may not be complete.
commitment_comparator(a, b)
Compare two commitment levels by their degree of finalization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Commitment
|
First commitment level. |
required |
b
|
Commitment
|
Second commitment level. |
required |
Returns:
| Type | Description |
|---|---|
Literal[-1, 0, 1]
|
-1 if |
Example
commitment_comparator(Commitment.FINALIZED, Commitment.PROCESSED) 1 commitment_comparator(Commitment.PROCESSED, Commitment.CONFIRMED) -1 commitment_comparator(Commitment.CONFIRMED, Commitment.CONFIRMED) 0
Source code in src/solana/rpc/commitment.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
get_commitment_score(commitment)
Return an integer score for a commitment level, with higher scores meaning more finalized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commitment
|
Commitment
|
The commitment level to score. |
required |
Returns:
| Type | Description |
|---|---|
int
|
An integer score (2 for FINALIZED, 1 for CONFIRMED, 0 for PROCESSED). |
Example
get_commitment_score(Commitment.FINALIZED) 2 get_commitment_score(Commitment.CONFIRMED) 1 get_commitment_score(Commitment.PROCESSED) 0
Source code in src/solana/rpc/commitment.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |