@@ -39,15 +39,12 @@ use wsts::net::NonceRequest;
39
39
pub struct BlockInfoV1 {
40
40
/// The associated packet nonce request if we have one
41
41
pub nonce_request : Option < NonceRequest > ,
42
- /// Whether this block is already being signed over
43
- pub signed_over : bool ,
44
42
}
45
43
46
44
impl From < NonceRequest > for BlockInfoV1 {
47
45
fn from ( value : NonceRequest ) -> Self {
48
46
Self {
49
47
nonce_request : Some ( value) ,
50
- signed_over : true ,
51
48
}
52
49
}
53
50
}
@@ -65,23 +62,6 @@ pub enum ExtraBlockInfo {
65
62
}
66
63
67
64
impl ExtraBlockInfo {
68
- /// Get `signed_over` if it exists
69
- pub fn get_signed_over ( & self ) -> Option < bool > {
70
- match self {
71
- ExtraBlockInfo :: None | ExtraBlockInfo :: V0 => None ,
72
- ExtraBlockInfo :: V1 ( v1) => Some ( v1. signed_over ) ,
73
- }
74
- }
75
- /// Set `signed_over` if it exists
76
- pub fn set_signed_over ( & mut self , value : bool ) -> Result < ( ) , & str > {
77
- match self {
78
- ExtraBlockInfo :: None | ExtraBlockInfo :: V0 => Err ( "Field doesn't exist" ) ,
79
- ExtraBlockInfo :: V1 ( v1) => {
80
- v1. signed_over = value;
81
- Ok ( ( ) )
82
- }
83
- }
84
- }
85
65
/// Take `nonce_request` if it exists
86
66
pub fn take_nonce_request ( & mut self ) -> Option < NonceRequest > {
87
67
match self {
@@ -114,6 +94,8 @@ pub struct BlockInfo {
114
94
pub vote : Option < NakamotoBlockVote > ,
115
95
/// Whether the block contents are valid
116
96
pub valid : Option < bool > ,
97
+ /// Whether this block is already being signed over
98
+ pub signed_over : bool ,
117
99
/// Time at which the proposal was received by this signer (epoch time in seconds)
118
100
pub proposed_time : u64 ,
119
101
/// Time at which the proposal was signed by this signer (epoch time in seconds)
@@ -132,6 +114,7 @@ impl From<BlockProposal> for BlockInfo {
132
114
reward_cycle : value. reward_cycle ,
133
115
vote : None ,
134
116
valid : None ,
117
+ signed_over : false ,
135
118
proposed_time : get_epoch_time_secs ( ) ,
136
119
signed_self : None ,
137
120
signed_group : None ,
@@ -144,15 +127,16 @@ impl BlockInfo {
144
127
pub fn new_v1_with_request ( block_proposal : BlockProposal , nonce_request : NonceRequest ) -> Self {
145
128
let mut block_info = BlockInfo :: from ( block_proposal) ;
146
129
block_info. ext = ExtraBlockInfo :: V1 ( BlockInfoV1 :: from ( nonce_request) ) ;
130
+ block_info. signed_over = true ;
147
131
block_info
148
132
}
149
133
150
134
/// Mark this block as valid, signed over, and record a timestamp in the block info if it wasn't
151
135
/// already set.
152
136
pub fn mark_signed_and_valid ( & mut self ) {
153
137
self . valid = Some ( true ) ;
138
+ self . signed_over = true ;
154
139
self . signed_self . get_or_insert ( get_epoch_time_secs ( ) ) ;
155
- _ = self . ext . set_signed_over ( true ) ;
156
140
}
157
141
158
142
/// Return the block's signer signature hash
@@ -407,7 +391,7 @@ impl SignerDb {
407
391
serde_json:: to_string ( & block_info) . expect ( "Unable to serialize block info" ) ;
408
392
let hash = & block_info. signer_signature_hash ( ) ;
409
393
let block_id = & block_info. block . block_id ( ) ;
410
- let signed_over = & block_info. ext . get_signed_over ( ) . unwrap_or ( false ) ;
394
+ let signed_over = & block_info. signed_over ;
411
395
let vote = block_info
412
396
. vote
413
397
. as_ref ( )
@@ -604,8 +588,6 @@ mod tests {
604
588
let db_path = tmp_db_path ( ) ;
605
589
let mut db = SignerDb :: new ( db_path) . expect ( "Failed to create signer db" ) ;
606
590
let ( mut block_info, block_proposal) = create_block ( ) ;
607
- // We'll need the V1 data fields for this
608
- block_info. ext = ExtraBlockInfo :: V1 ( BlockInfoV1 :: default ( ) ) ;
609
591
db. insert_block ( & block_info) . unwrap ( ) ;
610
592
611
593
assert ! ( db
0 commit comments