1
- use rand:: prelude:: * ;
2
- use rand:: distributions:: Standard ;
3
- use clvmr:: allocator:: NodePtr ;
4
- use clvm_traits:: { ToClvm , ClvmEncoder , ToClvmError , clvm_curried_args} ;
1
+ use clvm_traits:: { clvm_curried_args, ClvmEncoder , ToClvm , ToClvmError } ;
5
2
use clvm_utils:: CurriedProgram ;
3
+ use clvmr:: allocator:: NodePtr ;
4
+ use rand:: distributions:: Standard ;
5
+ use rand:: prelude:: * ;
6
6
7
- use crate :: common:: types:: { Amount , CoinString , PrivateKey , PublicKey , Aggsig , GameID , Puzzle , PuzzleHash , Error , Timeout , Hash , CoinID , AllocEncoder , IntoErr , SpecificTransactionBundle , Sha256tree } ;
8
7
use crate :: channel_handler:: game_handler:: GameHandler ;
9
8
use crate :: common:: standard_coin:: read_hex_puzzle;
9
+ use crate :: common:: types:: {
10
+ Aggsig , AllocEncoder , Amount , CoinID , CoinString , Error , GameID , Hash , IntoErr , PrivateKey ,
11
+ PublicKey , Puzzle , PuzzleHash , Sha256tree , SpecificTransactionBundle , Timeout ,
12
+ } ;
10
13
use crate :: referee:: RefereeMaker ;
11
14
12
15
#[ derive( Default ) ]
@@ -38,7 +41,7 @@ pub struct ChannelHandlerInitiationData {
38
41
39
42
pub struct ChannelHandlerInitiationResult {
40
43
pub channel_puzzle_hash_up : PuzzleHash ,
41
- pub my_initial_channel_half_signature_peer : Aggsig
44
+ pub my_initial_channel_half_signature_peer : Aggsig ,
42
45
}
43
46
44
47
pub struct PotatoSignatures {
@@ -59,18 +62,23 @@ pub struct GameStartInfo {
59
62
pub initial_state : NodePtr ,
60
63
pub initial_move : Vec < u8 > ,
61
64
pub initial_max_move_size : usize ,
62
- pub initial_mover_share : Amount
65
+ pub initial_mover_share : Amount ,
63
66
}
64
67
65
68
#[ derive( Clone ) ]
66
69
pub struct ReadableMove ( NodePtr ) ;
67
70
68
71
impl ReadableMove {
69
- pub fn from_nodeptr ( n : NodePtr ) -> Self { ReadableMove ( n) }
72
+ pub fn from_nodeptr ( n : NodePtr ) -> Self {
73
+ ReadableMove ( n)
74
+ }
70
75
}
71
76
72
77
impl ToClvm < NodePtr > for ReadableMove {
73
- fn to_clvm ( & self , encoder : & mut impl ClvmEncoder < Node = NodePtr > ) -> Result < NodePtr , ToClvmError > {
78
+ fn to_clvm (
79
+ & self ,
80
+ encoder : & mut impl ClvmEncoder < Node = NodePtr > ,
81
+ ) -> Result < NodePtr , ToClvmError > {
74
82
Ok ( self . 0 )
75
83
}
76
84
}
@@ -83,20 +91,20 @@ pub struct MoveResult {
83
91
pub move_peer : Vec < u8 > ,
84
92
pub validation_info_hash_peer : Hash ,
85
93
pub max_move_size_peer : usize ,
86
- pub mover_share_peer : Amount
94
+ pub mover_share_peer : Amount ,
87
95
}
88
96
89
97
pub struct OnChainGameCoin < ' a > {
90
98
pub game_id_up : GameID ,
91
99
pub coin_string_up : Option < CoinString > ,
92
- pub referee_up : & ' a RefereeMaker
100
+ pub referee_up : & ' a RefereeMaker ,
93
101
}
94
102
95
103
#[ derive( Clone ) ]
96
104
pub struct CoinSpentMoveUp {
97
105
pub game_id : GameID ,
98
106
pub spend_before_game_coin : SpecificTransactionBundle ,
99
- pub after_update_game_coin : CoinString
107
+ pub after_update_game_coin : CoinString ,
100
108
}
101
109
102
110
#[ derive( Clone ) ]
@@ -130,15 +138,18 @@ pub struct CoinSpentResult<'a> {
130
138
131
139
pub struct UnrollCoinSignatures {
132
140
pub to_create_unroll_coin : Aggsig ,
133
- pub to_spend_unroll_coin : Aggsig
141
+ pub to_spend_unroll_coin : Aggsig ,
134
142
}
135
143
136
144
pub fn read_unroll_metapuzzle ( allocator : & mut AllocEncoder ) -> Result < Puzzle , Error > {
137
145
read_hex_puzzle ( allocator, "resources/unroll_meta_puzzle.hex" )
138
146
}
139
147
140
148
pub fn read_unroll_puzzle ( allocator : & mut AllocEncoder ) -> Result < Puzzle , Error > {
141
- read_hex_puzzle ( allocator, "resources/unroll_puzzle_state_channel_unrolling.hex" )
149
+ read_hex_puzzle (
150
+ allocator,
151
+ "resources/unroll_puzzle_state_channel_unrolling.hex" ,
152
+ )
142
153
}
143
154
144
155
pub struct ChannelHandlerEnv < ' a , R : Rng > {
@@ -160,7 +171,7 @@ impl<'a, R: Rng> ChannelHandlerEnv<'a, R> {
160
171
unroll_metapuzzle : Puzzle ,
161
172
unroll_puzzle : Puzzle ,
162
173
referee_coin_puzzle : Puzzle ,
163
- agg_sig_me_additional_data : Hash
174
+ agg_sig_me_additional_data : Hash ,
164
175
) -> ChannelHandlerEnv < ' a , R > {
165
176
let referee_coin_puzzle_hash = referee_coin_puzzle. sha256tree ( allocator) ;
166
177
ChannelHandlerEnv {
@@ -170,14 +181,22 @@ impl<'a, R: Rng> ChannelHandlerEnv<'a, R> {
170
181
referee_coin_puzzle_hash,
171
182
unroll_metapuzzle,
172
183
unroll_puzzle,
173
- agg_sig_me_additional_data
184
+ agg_sig_me_additional_data,
174
185
}
175
186
}
176
187
177
- pub fn curried_unroll_puzzle ( & mut self , old_seq_number : u64 , default_conditions_hash : PuzzleHash ) -> Result < Puzzle , Error > {
188
+ pub fn curried_unroll_puzzle (
189
+ & mut self ,
190
+ old_seq_number : u64 ,
191
+ default_conditions_hash : PuzzleHash ,
192
+ ) -> Result < Puzzle , Error > {
178
193
let curried_program = CurriedProgram {
179
194
program : self . unroll_puzzle . clone ( ) ,
180
- args : clvm_curried_args ! ( self . unroll_metapuzzle. clone( ) , old_seq_number, default_conditions_hash)
195
+ args : clvm_curried_args ! (
196
+ self . unroll_metapuzzle. clone( ) ,
197
+ old_seq_number,
198
+ default_conditions_hash
199
+ ) ,
181
200
} ;
182
201
let nodeptr = curried_program. to_clvm ( self . allocator ) . into_gen ( ) ?;
183
202
Ok ( Puzzle :: from_nodeptr ( nodeptr) )
@@ -206,5 +225,5 @@ pub struct PotatoMoveCachedData {
206
225
pub enum CachedPotatoRegenerateLastHop {
207
226
PotatoCreatedGame ( Vec < GameID > , Amount , Amount ) ,
208
227
PotatoAccept ( PotatoAcceptCachedData ) ,
209
- PotatoMoveHappening ( PotatoMoveCachedData )
228
+ PotatoMoveHappening ( PotatoMoveCachedData ) ,
210
229
}
0 commit comments