Document order of recent blockhashes sysvar
I wanted to use this sysvar to get a recent block hash, but I didn't know whether the first or the last entry contains the most recent block hash. By calling it for mainnet, printing the results, and comparing that to the recent blocks on solanabeach.io/blocks, I discovered that the entries are ordered from most recent to least recent. Document this to save future readers the trouble.
This commit is contained in:
parent
25ac664106
commit
94ab0eb49f
|
@ -97,7 +97,9 @@ other instructions in the same transaction. Read more information on
|
||||||
## RecentBlockhashes
|
## RecentBlockhashes
|
||||||
|
|
||||||
The RecentBlockhashes sysvar contains the active recent blockhashes as well as
|
The RecentBlockhashes sysvar contains the active recent blockhashes as well as
|
||||||
their associated fee calculators. It is updated every slot.
|
their associated fee calculators. It is updated every slot. Entries are ordered
|
||||||
|
by descending block height, so the first entry holds the most recent block hash,
|
||||||
|
and the last entry holds an old block hash.
|
||||||
|
|
||||||
- Address: `SysvarRecentB1ockHashes11111111111111111111`
|
- Address: `SysvarRecentB1ockHashes11111111111111111111`
|
||||||
- Layout:
|
- Layout:
|
||||||
|
|
|
@ -53,6 +53,10 @@ impl<'a> PartialOrd for IterItem<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Contains recent block hashes and fee calculators.
|
||||||
|
///
|
||||||
|
/// The entries are ordered by descending block height, so the first entry holds
|
||||||
|
/// the most recent block hash, and the last entry holds an old block hash.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||||
pub struct RecentBlockhashes(Vec<Entry>);
|
pub struct RecentBlockhashes(Vec<Entry>);
|
||||||
|
|
Loading…
Reference in New Issue