-
Notifications
You must be signed in to change notification settings - Fork 11
/
lib.rs
170 lines (132 loc) · 5.01 KB
/
lib.rs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
use drillx::Solution;
use serde::{Deserialize, Serialize};
use solana_sdk::{hash::Hash, pubkey::Pubkey, signature::Signature, transaction::Transaction};
///////////////////////////////////////////////////////////////////////////
/// Request ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
#[derive(Debug, Deserialize, Serialize)]
pub struct RegisterPayload {
/// The authority of the member account sending the payload.
pub authority: Pubkey,
}
#[derive(Debug, Deserialize)]
pub struct GetMemberPayload {
/// The authority of the member account sending the payload.
pub authority: String,
}
#[derive(Debug, Deserialize)]
pub struct GetChallengePayload {
/// The authority of the member account sending the payload.
pub authority: String,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct ContributePayload {
/// The authority of the member account sending the payload.
pub authority: Pubkey,
/// The solution submitted.
pub solution: Solution,
/// Must be a valid signature of the solution
pub signature: Signature,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct UpdateBalancePayload {
/// The authority of the member account sending the payload.
pub authority: Pubkey,
/// The transaction containing the attribute instruction
/// signed by the client as fee payer.
pub transaction: Transaction,
/// The hash used to signed the transaction on the client.
pub hash: Hash,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct RegisterStakerPayload {
/// The authority of the member account sending the payload.
pub authority: Pubkey,
/// The mint for the boost account the member is staking to.
pub mint: Pubkey,
}
///////////////////////////////////////////////////////////////////////////
/// Response //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
#[derive(Debug, Deserialize, Serialize)]
pub struct PoolAddress {
/// The pubkey address of the pool pda of this operator.
pub address: Pubkey,
/// The bump returned when deriving the pda.
pub bump: u8,
}
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct Challenge {
/// The current challenge the pool is accepting solutions for.
pub challenge: [u8; 32],
/// Foreign key to the ORE proof account.
pub lash_hash_at: i64,
// The current minimum difficulty accepted by the ORE program.
pub min_difficulty: u64,
// The cutoff time to stop accepting contributions.
pub cutoff_time: u64,
}
/// The member record that sits in the operator database
#[derive(Debug, Serialize, Deserialize)]
pub struct Member {
/// The respective pda pubkey of the on-chain account.
pub address: String,
/// The id as assigned by the on-chain program.
pub id: i64,
/// The authority pubkey of this account.
pub authority: String,
/// The pool pubkey this account belongs to.
pub pool_address: String,
/// The total balance assigned to this account.
/// Always increments for idempotent on-chain updates.
pub total_balance: i64,
/// Whether or not this member is approved by the operator.
pub is_approved: bool,
/// Whether or not this member is KYC'd by the operator.
pub is_kyc: bool,
/// Whether or not this member's on-chain balance is in sync with the operator db balance.
pub is_synced: bool,
}
/// The staker record that sits in the operator database
#[derive(Debug, Serialize, Deserialize)]
pub struct Staker {
/// the share account address
pub address: Pubkey,
/// the member id (foreign key relation to members table)
pub member_id: u64,
/// the mint of the boost account the member is staking to
pub mint: Pubkey,
/// whether or not this account has been added to the webhook
pub webhook: bool,
}
/// The response from the /challenge request.
#[derive(Debug, Serialize, Deserialize)]
pub struct MemberChallenge {
/// The challenge to mine for.
pub challenge: Challenge,
/// Additional seconds to be subtracted from the cuttoff time
/// to create a "submission window".
pub buffer: u64,
/// The number of total members to divide the nonce space by.
pub num_total_members: u64,
}
/// The response from the /challenge request.
#[derive(Debug, Serialize, Deserialize)]
pub struct MemberChallengeV2 {
/// The challenge to mine for.
pub challenge: Challenge,
/// The number of total members to divide the nonce space by.
pub num_total_members: u64,
/// The id/index for distinguishing devices the client is using.
pub device_id: u8,
/// The number of client devices permitted per member.
pub num_devices: u8,
}
/// The response from the update-balance request.
#[derive(Debug, Serialize, Deserialize)]
pub struct BalanceUpdate {
/// The balance updated on-chain.
pub balance: u64,
/// The transaction signature.
pub signature: Signature,
}