File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
storage/txpool/src/service Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -112,14 +112,22 @@ fn promote(
112
112
let env_inner = env. env_inner ( ) ;
113
113
let tx_rw = env_inner. tx_rw ( ) ?;
114
114
115
- let mut tx_infos = env_inner. open_db_rw :: < TransactionInfos > ( & tx_rw) ?;
115
+ let res = || {
116
+ let mut tx_infos = env_inner. open_db_rw :: < TransactionInfos > ( & tx_rw) ?;
116
117
117
- tx_infos. update ( tx_hash, |mut info| {
118
- info. flags . remove ( TxStateFlags :: STATE_STEM ) ;
119
- Some ( info)
120
- } ) ?;
118
+ tx_infos. update ( tx_hash, |mut info| {
119
+ info. flags . remove ( TxStateFlags :: STATE_STEM ) ;
120
+ Some ( info)
121
+ } )
122
+ } ;
123
+
124
+ if let Err ( e) = res ( ) {
125
+ // error promoting the tx, abort the DB transaction.
126
+ TxRw :: abort ( tx_rw)
127
+ . expect ( "could not maintain database atomicity by aborting write transaction" ) ;
121
128
122
- drop ( tx_infos) ;
129
+ return Err ( e) ;
130
+ }
123
131
124
132
TxRw :: commit ( tx_rw) ?;
125
133
Ok ( TxpoolWriteResponse :: Ok )
You can’t perform that action at this time.
0 commit comments