Open linuskendall opened 1 year ago
See also #47, which can be a first version (not sure if it can include the solana validator version?).
linuskendall: for getLatestBlockhash if we can we should use the existing interface I think via block notification + slot notification
share read/write design for MessageBlockMeta
// plugin.rs
#[derive(Debug)]
pub struct PluginInner {
// ...
latest_block_meta: Arc<RwLock<Option<MessageBlockMeta>>>,
}
// grpc.rs
#[derive(Clone)]
pub struct GrpcService {
// ...
latest_block_meta: Arc<RwLock<Option<MessageBlockMeta>>>,
}
// plugin.rs
fn notify_block_metadata(
&mut self,
blockinfo: ReplicaBlockInfoVersions<'_>,
) -> PluginResult<()> {
// ...
if let Ok(mut latest_block_meta_write_guard) = inner.latest_block_meta.write() {
*latest_block_meta_write_guard = Some(block_meta.clone());
}
}
// grpc.rs
async fn get_latest_blockhash(&self, _request: Request<GetLatestBlockhashRequest>) -> Result<Response<GetLatestBlockhashResponse>, Status> {
if let Ok(message_block_meta) = self.latest_block_meta.read() {
let v= message_block_meta.as_ref();
if let Some(v) = v {
let response = GetLatestBlockhashResponse {
slot: v.slot,
blockhash: v.blockhash.clone(),
block_height: v.block_height.unwrap(),
};
return Ok(Response::new(response));
}
}
Err(Status::internal("latest_block_meta is None"))
}
one more question for isBlockhashValid/is_blockhash_valid:
in Solana validator, we could hold a ArcBank
instance, and query blockhash within the Bank
We could use the following method:
The potential issue here is:
only newly added blockhashes are recorded at startup, and historical blockhashes are not recorded. it may be necessary to maintain a separate historical database for querying.
I would like to add non streaming methods that could help users who are writing trading code:
Harder ones that we could potentially do if we add much more logic to the code
Ones that I don't know if possible (what info would we require to do this? maybe some modification to geyser interface to send some of this info on start up):
Others..?