harbor run -t openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-8910harbor download openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-8910You need to implement the BlockhashQuery struct's methods to handle queries related to blockhash and fee calculators in a blockchain context, as specified by the provided test code.
Requirements:
New Method Implementation:
Add a method new that constructs a BlockhashQuery based on the following input parameters:
blockhash: Option<Hash>: If Some(hash), it indicates a specific blockhash; if None, it indicates that the query should request all available blockhashes.sign_only: bool: If true, the query should indicate that only the blockhash is needed without fee calculation.nonce_account: Option<Pubkey>: If provided, this indicates that the information should be derived from the nonce account; otherwise, it defaults to the cluster.Based on the parameters:
blockhash is Some(hash) and sign_only is true, return BlockhashQuery::None(hash).blockhash is Some(hash) and sign_only is false, derive the source (using the nonce account if available) and return BlockhashQuery::FeeCalculator(source, hash).blockhash is None and sign_only is false, return BlockhashQuery::All(source).blockhash is None and sign_only is true.new_from_matches Method Implementation:
new_from_matches which constructs a BlockhashQuery from ArgMatches.blockhash, sign_only, and nonce_account fields appropriately.get_blockhash_and_fee_calculator Method Implementation:
get_blockhash_and_fee_calculator which, based on the type of BlockhashQuery, retrieves the associated blockhash and fee calculator.rpc_client to make RPC calls to retrieve the necessary information depending on the source (Cluster or NonceAccount).Default Implementation:
Default trait for BlockhashQuery to set its default value to BlockhashQuery::All(Source::Cluster).Error Handling:
These implementations must ensure that all the tests provided in the test module pass successfully. Place your implementation in the /app/ directory in the appropriate Rust file.