pub fn save_new_eth_tx(
        &self,
        op_type: OperationType,
        op_id: Option<i64>,
        last_deadline_block: i64,
        last_used_gas_price: BigUint,
        raw_tx: Vec<u8>,
    ) -> QueryResult<InsertedOperationResponse> {
        self.0.conn().transaction(|| {
            // It's important to assign nonce within the same db transaction
            // as saving the operation to avoid the state divergence.
            let nonce = self.get_next_nonce()?;

            // Create and insert the operation.
            let operation = NewETHOperation {
                op_type: op_type.to_string(),
                nonce,
                last_deadline_block,
                last_used_gas_price: last_used_gas_price.into(),
                raw_tx,
            };

            let inserted_tx = insert_into(eth_operations::table)
                .values(&operation)
                .returning(eth_operations::id)
                .get_results(self.0.conn())?;
            assert_eq!(
                inserted_tx.len(),
                1,
                "Wrong amount of updated rows (eth_operations)"
            );

            // Obtain the operation ID for the follow-up queried.
            let eth_op_id = inserted_tx[0];

            // // Add a hash entry.
            // let hash_entry = NewETHTxHash {
            //     eth_op_id,
            //     tx_hash: hash.as_bytes().to_vec(),
            // };
            // let inserted_hashes_rows = insert_into(eth_tx_hashes::table)
            //     .values(&hash_entry)
            //     .execute(self.0.conn())?;
            // assert_eq!(
            //     inserted_hashes_rows, 1,
            //     "Wrong amount of updated rows (eth_tx_hashes)"
            // );

            // If the operation ID was provided, we should also insert a binding entry.
            if let Some(op_id) = op_id {
                let binding = NewETHBinding { op_id, eth_op_id };

                insert_into(eth_ops_binding::table)
                    .values(&binding)
                    .execute(self.0.conn())?;
            }

            // Update the stored stats.
            self.report_created_operation(op_type)?;

            // Return the assigned ID and nonce.
            let response = InsertedOperationResponse {
                id: eth_op_id,
                nonce: nonce.into(),
            };

            Ok(response)
        })
    }
/// Stores the sent (but not confirmed yet) Ethereum transaction in the database.
/// Returns the `ETHOperation` object containing the assigned nonce and operation ID.
Stores the sent (but not confirmed yet) Ethereum transaction in the database.
Returns the `ETHOperation` object containing the assigned nonce and operation ID.
Stores the sent ( but not confirmed yet ) Ethereum transaction in the database . Returns the ` ETHOperation ` object containing the assigned nonce and operation ID .
pub fn save_new_eth_tx(
        &self,
        op_type: OperationType,
        op_id: Option<i64>,
        last_deadline_block: i64,
        last_used_gas_price: BigUint,
        raw_tx: Vec<u8>,
    ) -> QueryResult<InsertedOperationResponse> {
        self.0.conn().transaction(|| {
            // It's important to assign nonce within the same db transaction
            // as saving the operation to avoid the state divergence.
            let nonce = self.get_next_nonce()?;
            // Create and insert the operation.
            let operation = NewETHOperation {
                op_type: op_type.to_string(),
                nonce,
                last_deadline_block,
                last_used_gas_price: last_used_gas_price.into(),
                raw_tx,
            };
            let inserted_tx = insert_into(eth_operations::table)
                .values(&operation)
                .returning(eth_operations::id)
                .get_results(self.0.conn())?;
            assert_eq!(
                inserted_tx.len(),
                1,
                "Wrong amount of updated rows (eth_operations)"
            );
            // Obtain the operation ID for the follow-up queried.
            let eth_op_id = inserted_tx[0];
            // // Add a hash entry.
            // let hash_entry = NewETHTxHash {
            //     eth_op_id,
            //     tx_hash: hash.as_bytes().to_vec(),
            // };
            // let inserted_hashes_rows = insert_into(eth_tx_hashes::table)
            //     .values(&hash_entry)
            //     .execute(self.0.conn())?;
            // assert_eq!(
            //     inserted_hashes_rows, 1,
            //     "Wrong amount of updated rows (eth_tx_hashes)"
            // );
            // If the operation ID was provided, we should also insert a binding entry.
            if let Some(op_id) = op_id {
                let binding = NewETHBinding { op_id, eth_op_id };
                insert_into(eth_ops_binding::table)
                    .values(&binding)
                    .execute(self.0.conn())?;
            }
            // Update the stored stats.
            self.report_created_operation(op_type)?;
            // Return the assigned ID and nonce.
            let response = InsertedOperationResponse {
                id: eth_op_id,
                nonce: nonce.into(),
            };
            Ok(response)
        })
    }
pub fn save_new_eth_tx ( & self , op_type : OperationType , op_id : Option < i64 > , last_deadline_block : i64 , last_used_gas_price : BigUint , raw_tx : Vec < u8 > , ) -> QueryResult < InsertedOperationResponse > { self . 0 . conn ( ) . transaction ( | | { // It's important to assign nonce within the same db transaction // as saving the operation to avoid the state divergence. let nonce = self . get_next_nonce ( ) ? ; // Create and insert the operation. let operation = NewETHOperation { op_type : op_type . to_string ( ) , nonce , last_deadline_block , last_used_gas_price : last_used_gas_price . into ( ) , raw_tx , } ; let inserted_tx = insert_into ( eth_operations :: table ) . values ( & operation ) . returning ( eth_operations :: id ) . get_results ( self . 0 . conn ( ) ) ? ; assert_eq ! ( inserted_tx len ( ) 1 " " ) ; // Obtain the operation ID for the follow-up queried. let eth_op_id = inserted_tx [ 0 ] ; // // Add a hash entry. // let hash_entry = NewETHTxHash { //     eth_op_id, //     tx_hash: hash.as_bytes().to_vec(), // }; // let inserted_hashes_rows = insert_into(eth_tx_hashes::table) //     .values(&hash_entry) //     .execute(self.0.conn())?; // assert_eq!( //     inserted_hashes_rows, 1, //     "Wrong amount of updated rows (eth_tx_hashes)" // ); // If the operation ID was provided, we should also insert a binding entry. if let Some ( op_id ) = op_id { let binding = NewETHBinding { op_id , eth_op_id } ; insert_into ( eth_ops_binding :: table ) . values ( & binding ) . execute ( self . 0 . conn ( ) ) ? ; } // Update the stored stats. self . report_created_operation ( op_type ) ? ; // Return the assigned ID and nonce. let response = InsertedOperationResponse { id : eth_op_id , nonce : nonce . into ( ) , } ; Ok ( response ) } ) }
Stores the sent (but not confirmed yet) Ethereum transaction in the database.
Stores the sent ( but not confirmed yet ) Ethereum transaction in the database .
&self
op_type
OperationType
op_id
Option<i64>
last_deadline_block
i64
last_used_gas_price
BigUint
raw_tx
Vec<u8>