@@ -43,34 +43,39 @@ impl gasket::framework::Worker<Stage> for Worker {
43
43
async fn execute ( & mut self , unit : & ChainEvent , stage : & mut Stage ) -> Result < ( ) , WorkerError > {
44
44
let point = unit. point ( ) . clone ( ) ;
45
45
46
- let template = match unit {
46
+ let templates = match unit {
47
47
ChainEvent :: Apply ( p, r) => {
48
48
let data = hbs_data ( p. clone ( ) , Some ( r. clone ( ) ) ) ;
49
- match r {
49
+ let template = match r {
50
50
Record :: CborBlock ( _) => stage. templates . render ( "apply_cbor_block" , & data) ,
51
51
Record :: CborTx ( _) => stage. templates . render ( "apply_cbor_tx" , & data) ,
52
52
_ => stage. templates . render ( "apply" , & data) ,
53
- }
53
+ } ;
54
+ vec ! [ template]
54
55
}
55
56
ChainEvent :: Undo ( p, r) => {
56
57
let data = hbs_data ( p. clone ( ) , Some ( r. clone ( ) ) ) ;
57
- match r {
58
+ let template = match r {
58
59
Record :: CborBlock ( _) => stage. templates . render ( "undo_cbor_block" , & data) ,
59
60
Record :: CborTx ( _) => stage. templates . render ( "undo_cbor_tx" , & data) ,
60
61
_ => stage. templates . render ( "undo" , & data) ,
61
- }
62
+ } ;
63
+ vec ! [ template]
62
64
}
63
65
ChainEvent :: Reset ( p) => {
64
66
let data = hbs_data ( p. clone ( ) , None ) ;
65
- stage. templates . render ( "reset_cbor_block" , & data) . ok ( ) ;
66
- stage. templates . render ( "reset_cbor_tx" , & data)
67
+ vec ! [
68
+ stage. templates. render( "reset_cbor_block" , & data) ,
69
+ stage. templates. render( "reset_cbor_tx" , & data) ,
70
+ ]
67
71
}
68
72
} ;
69
73
70
- let statement = template. or_panic ( ) ?;
71
-
72
- let result = sqlx:: query ( & statement) . execute ( & self . db ) . await . or_retry ( ) ?;
73
- debug ! ( rows = result. rows_affected( ) , "sql statement executed" ) ;
74
+ for template in templates {
75
+ let statement = template. or_panic ( ) ?;
76
+ let result = sqlx:: query ( & statement) . execute ( & self . db ) . await . or_retry ( ) ?;
77
+ debug ! ( rows = result. rows_affected( ) , "sql statement executed" ) ;
78
+ }
74
79
75
80
stage. ops_count . inc ( 1 ) ;
76
81
stage. latest_block . set ( point. slot_or_default ( ) as i64 ) ;
0 commit comments