1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Support for obtaining current bids from the auction system.
use crate::tracking_copy::TrackingCopyError;
use casper_types::{system::auction::BidKind, Digest};
/// Represents a request to obtain current bids in the auction system.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BidsRequest {
state_hash: Digest,
}
impl BidsRequest {
/// Creates new request.
pub fn new(state_hash: Digest) -> Self {
BidsRequest { state_hash }
}
/// Returns state root hash.
pub fn state_hash(&self) -> Digest {
self.state_hash
}
}
/// Represents a result of a `get_bids` request.
#[derive(Debug)]
pub enum BidsResult {
/// Invalid state root hash.
RootNotFound,
/// Contains current bids returned from the global state.
Success {
/// Current bids.
bids: Vec<BidKind>,
},
/// Failure.
Failure(TrackingCopyError),
}
impl BidsResult {
/// Returns wrapped [`Vec<BidKind>`] if this represents a successful query result.
pub fn into_option(self) -> Option<Vec<BidKind>> {
if let Self::Success { bids } = self {
Some(bids)
} else {
None
}
}
}