diff --git a/pallas-applying/tests/byron.rs b/pallas-applying/tests/byron.rs index 56ed33e0..325f212b 100644 --- a/pallas-applying/tests/byron.rs +++ b/pallas-applying/tests/byron.rs @@ -55,8 +55,8 @@ mod byron_tests { let utxos: UTxOs = mk_utxo_for_single_input_tx( &mtxp.transaction, String::from(include_str!("../../test_data/byron2.address")), - // The number of lovelace in this input is irrelevant, since no fees have to be paid for - // this transaction. + // The number of lovelace in this input is irrelevant, since no fees have to be paid + // for this transaction. 1, ); let env: Environment = Environment { @@ -324,7 +324,8 @@ mod byron_tests { } #[test] - // The input to the transaction has an associated witness, but the signature is wrong. + // The input to the transaction has an associated witness, but the signature is + // wrong. fn wrong_signature() { let cbor_bytes: Vec = cbor_to_bytes(include_str!("../../test_data/byron1.tx")); let mut mtxp: MintedTxPayload = mainnet_tx_from_bytes_cbor(&cbor_bytes); @@ -374,9 +375,10 @@ fn add_to_utxo<'a>(utxos: &mut UTxOs<'a>, tx_in: TxIn, tx_out: TxOut) { utxos.insert(multi_era_in, multi_era_out); } -// pallas_applying::validate takes a MultiEraTx, not a Tx and a Witnesses. To be able to build a -// MultiEraTx from a Tx and a Witnesses, we need to encode each of them and then decode them into -// KeepRaw and KeepRaw values, respectively, to be able to make the MultiEraTx value. +// pallas_applying::validate takes a MultiEraTx, not a Tx and a Witnesses. To be +// able to build a MultiEraTx from a Tx and a Witnesses, we need to encode each +// of them and then decode them into KeepRaw and KeepRaw values, +// respectively, to be able to make the MultiEraTx value. fn mk_byron_tx_and_validate( tx: &Tx, wits: &Witnesses, @@ -388,7 +390,7 @@ fn mk_byron_tx_and_validate( Ok(_) => (), Err(err) => assert!(false, "Unable to encode Tx ({:?}).", err), }; - let kptx: KeepRaw = match Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()) { + let kptx: KeepRaw = match Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()) { Ok(kp) => kp, Err(err) => panic!("Unable to decode Tx ({:?}).", err), }; @@ -399,7 +401,7 @@ fn mk_byron_tx_and_validate( Err(err) => assert!(false, "Unable to encode Witnesses ({:?}).", err), }; let kpwit: KeepRaw = - match Decode::decode(&mut Decoder::new(&wit_buf.as_slice()), &mut ()) { + match Decode::decode(&mut Decoder::new(wit_buf.as_slice()), &mut ()) { Ok(kp) => kp, Err(err) => panic!("Unable to decode Witnesses ({:?}).", err), }; diff --git a/pallas-codec/src/flat/decode/decoder.rs b/pallas-codec/src/flat/decode/decoder.rs index c79b15b7..63dc8fd5 100644 --- a/pallas-codec/src/flat/decode/decoder.rs +++ b/pallas-codec/src/flat/decode/decoder.rs @@ -27,11 +27,13 @@ impl<'b> Decoder<'b> { /// Decode an integer of any size. /// This is byte alignment agnostic. /// First we decode the next 8 bits of the buffer. - /// We take the 7 least significant bits as the 7 least significant bits of the current unsigned integer. - /// If the most significant bit of the 8 bits is 1 then we take the next 8 and repeat the process above, - /// filling in the next 7 least significant bits of the unsigned integer and so on. - /// If the most significant bit was instead 0 we stop decoding any more bits. - /// Finally we use zigzag to convert the unsigned integer back to a signed integer. + /// We take the 7 least significant bits as the 7 least significant bits of + /// the current unsigned integer. If the most significant bit of the 8 + /// bits is 1 then we take the next 8 and repeat the process above, + /// filling in the next 7 least significant bits of the unsigned integer and + /// so on. If the most significant bit was instead 0 we stop decoding + /// any more bits. Finally we use zigzag to convert the unsigned integer + /// back to a signed integer. pub fn integer(&mut self) -> Result { Ok(zigzag::to_isize(self.word()?)) } @@ -39,11 +41,13 @@ impl<'b> Decoder<'b> { /// Decode an integer of 128 bits size. /// This is byte alignment agnostic. /// First we decode the next 8 bits of the buffer. - /// We take the 7 least significant bits as the 7 least significant bits of the current unsigned integer. - /// If the most significant bit of the 8 bits is 1 then we take the next 8 and repeat the process above, - /// filling in the next 7 least significant bits of the unsigned integer and so on. - /// If the most significant bit was instead 0 we stop decoding any more bits. - /// Finally we use zigzag to convert the unsigned integer back to a signed integer. + /// We take the 7 least significant bits as the 7 least significant bits of + /// the current unsigned integer. If the most significant bit of the 8 + /// bits is 1 then we take the next 8 and repeat the process above, + /// filling in the next 7 least significant bits of the unsigned integer and + /// so on. If the most significant bit was instead 0 we stop decoding + /// any more bits. Finally we use zigzag to convert the unsigned integer + /// back to a signed integer. pub fn big_integer(&mut self) -> Result { Ok(zigzag::to_i128(self.big_word()?)) } @@ -70,9 +74,10 @@ impl<'b> Decoder<'b> { /// Decodes a filler to byte align the buffer, /// then decodes the next byte to get the array length up to a max of 255. /// We decode bytes equal to the array length to form the byte array. - /// If the following byte for array length is not 0 we decode it and repeat above to continue decoding the byte array. - /// We stop once we hit a byte array length of 0. - /// If array length is 0 for first byte array length the we return a empty array. + /// If the following byte for array length is not 0 we decode it and repeat + /// above to continue decoding the byte array. We stop once we hit a + /// byte array length of 0. If array length is 0 for first byte array + /// length the we return a empty array. pub fn bytes(&mut self) -> Result, Error> { self.filler()?; self.byte_array() @@ -81,10 +86,12 @@ impl<'b> Decoder<'b> { /// Decode a 32 bit char. /// This is byte alignment agnostic. /// First we decode the next 8 bits of the buffer. - /// We take the 7 least significant bits as the 7 least significant bits of the current unsigned integer. - /// If the most significant bit of the 8 bits is 1 then we take the next 8 and repeat the process above, - /// filling in the next 7 least significant bits of the unsigned integer and so on. - /// If the most significant bit was instead 0 we stop decoding any more bits. + /// We take the 7 least significant bits as the 7 least significant bits of + /// the current unsigned integer. If the most significant bit of the 8 + /// bits is 1 then we take the next 8 and repeat the process above, + /// filling in the next 7 least significant bits of the unsigned integer and + /// so on. If the most significant bit was instead 0 we stop decoding + /// any more bits. pub fn char(&mut self) -> Result { let character = self.word()? as u32; @@ -105,9 +112,10 @@ impl<'b> Decoder<'b> { /// Decodes a filler to byte align the buffer, /// then decodes the next byte to get the array length up to a max of 255. /// We decode bytes equal to the array length to form the byte array. - /// If the following byte for array length is not 0 we decode it and repeat above to continue decoding the byte array. - /// We stop once we hit a byte array length of 0. - /// If array length is 0 for first byte array length the we return a empty array. + /// If the following byte for array length is not 0 we decode it and repeat + /// above to continue decoding the byte array. We stop once we hit a + /// byte array length of 0. If array length is 0 for first byte array + /// length the we return a empty array. pub fn utf8(&mut self) -> Result { // TODO: Better Error Handling String::from_utf8(Vec::::decode(self)?).map_err(Error::from) @@ -124,10 +132,12 @@ impl<'b> Decoder<'b> { /// Decode a word of any size. /// This is byte alignment agnostic. /// First we decode the next 8 bits of the buffer. - /// We take the 7 least significant bits as the 7 least significant bits of the current unsigned integer. - /// If the most significant bit of the 8 bits is 1 then we take the next 8 and repeat the process above, - /// filling in the next 7 least significant bits of the unsigned integer and so on. - /// If the most significant bit was instead 0 we stop decoding any more bits. + /// We take the 7 least significant bits as the 7 least significant bits of + /// the current unsigned integer. If the most significant bit of the 8 + /// bits is 1 then we take the next 8 and repeat the process above, + /// filling in the next 7 least significant bits of the unsigned integer and + /// so on. If the most significant bit was instead 0 we stop decoding + /// any more bits. pub fn word(&mut self) -> Result { let mut leading_bit = 1; let mut final_word: usize = 0; @@ -146,10 +156,12 @@ impl<'b> Decoder<'b> { /// Decode a word of 128 bits size. /// This is byte alignment agnostic. /// First we decode the next 8 bits of the buffer. - /// We take the 7 least significant bits as the 7 least significant bits of the current unsigned integer. - /// If the most significant bit of the 8 bits is 1 then we take the next 8 and repeat the process above, - /// filling in the next 7 least significant bits of the unsigned integer and so on. - /// If the most significant bit was instead 0 we stop decoding any more bits. + /// We take the 7 least significant bits as the 7 least significant bits of + /// the current unsigned integer. If the most significant bit of the 8 + /// bits is 1 then we take the next 8 and repeat the process above, + /// filling in the next 7 least significant bits of the unsigned integer and + /// so on. If the most significant bit was instead 0 we stop decoding + /// any more bits. pub fn big_word(&mut self) -> Result { let mut leading_bit = 1; let mut final_word: u128 = 0; @@ -169,8 +181,8 @@ impl<'b> Decoder<'b> { /// This is byte alignment agnostic. /// Decode a bit from the buffer. /// If 0 then stop. - /// Otherwise we decode an item in the list with the decoder function passed in. - /// Then decode the next bit in the buffer and repeat above. + /// Otherwise we decode an item in the list with the decoder function passed + /// in. Then decode the next bit in the buffer and repeat above. /// Returns a list of items decoded with the decoder function. pub fn decode_list_with(&mut self, decoder_func: F) -> Result, Error> where @@ -228,9 +240,10 @@ impl<'b> Decoder<'b> { /// Throws a BufferNotByteAligned error if the buffer is not byte aligned /// Decodes the next byte to get the array length up to a max of 255. /// We decode bytes equal to the array length to form the byte array. - /// If the following byte for array length is not 0 we decode it and repeat above to continue decoding the byte array. - /// We stop once we hit a byte array length of 0. - /// If array length is 0 for first byte array length the we return a empty array. + /// If the following byte for array length is not 0 we decode it and repeat + /// above to continue decoding the byte array. We stop once we hit a + /// byte array length of 0. If array length is 0 for first byte array + /// length the we return a empty array. fn byte_array(&mut self) -> Result, Error> { if self.used_bits != 0 { return Err(Error::BufferNotByteAligned); @@ -265,10 +278,11 @@ impl<'b> Decoder<'b> { /// This is byte alignment agnostic. /// If num_bits is greater than the 8 we throw an IncorrectNumBits error. /// First we decode the next num_bits of bits in the buffer. - /// If there are less unused bits in the current byte in the buffer than num_bits, - /// then we decode the remaining bits from the most significant bits in the next byte in the buffer. - /// Otherwise we decode the unused bits from the current byte. - /// Returns the decoded value up to a byte in size. + /// If there are less unused bits in the current byte in the buffer than + /// num_bits, then we decode the remaining bits from the most + /// significant bits in the next byte in the buffer. Otherwise we decode + /// the unused bits from the current byte. Returns the decoded value up + /// to a byte in size. pub fn bits8(&mut self, num_bits: usize) -> Result { if num_bits > 8 { return Err(Error::IncorrectNumBits); @@ -292,7 +306,8 @@ impl<'b> Decoder<'b> { } /// Ensures the buffer has the required bytes passed in by required_bytes. - /// Throws a NotEnoughBytes error if there are less bytes remaining in the buffer than required_bytes. + /// Throws a NotEnoughBytes error if there are less bytes remaining in the + /// buffer than required_bytes. fn ensure_bytes(&mut self, required_bytes: usize) -> Result<(), Error> { if required_bytes as isize > self.buffer.len() as isize - self.pos as isize { Err(Error::NotEnoughBytes(required_bytes)) @@ -302,7 +317,8 @@ impl<'b> Decoder<'b> { } /// Ensures the buffer has the required bits passed in by required_bits. - /// Throws a NotEnoughBits error if there are less bits remaining in the buffer than required_bits. + /// Throws a NotEnoughBits error if there are less bits remaining in the + /// buffer than required_bits. fn ensure_bits(&mut self, required_bits: usize) -> Result<(), Error> { if required_bits as isize > (self.buffer.len() as isize - self.pos as isize) * 8 - self.used_bits as isize diff --git a/pallas-codec/src/flat/encode/encoder.rs b/pallas-codec/src/flat/encode/encoder.rs index 844ed087..d17525b7 100644 --- a/pallas-codec/src/flat/encode/encoder.rs +++ b/pallas-codec/src/flat/encode/encoder.rs @@ -34,7 +34,8 @@ impl Encoder { } /// Encode 1 unsigned byte. - /// Uses the next 8 bits in the buffer, can be byte aligned or byte unaligned + /// Uses the next 8 bits in the buffer, can be byte aligned or byte + /// unaligned pub fn u8(&mut self, x: u8) -> Result<&mut Self, Error> { if self.used_bits == 0 { self.current_byte = x; @@ -60,10 +61,11 @@ impl Encoder { } /// Encode a byte array. - /// Uses filler to byte align the buffer, then writes byte array length up to 255. - /// Following that it writes the next 255 bytes from the array. - /// We repeat writing length up to 255 and the next 255 bytes until we reach the end of the byte array. - /// After reaching the end of the byte array we write a 0 byte. Only write 0 byte if the byte array is empty. + /// Uses filler to byte align the buffer, then writes byte array length up + /// to 255. Following that it writes the next 255 bytes from the array. + /// We repeat writing length up to 255 and the next 255 bytes until we reach + /// the end of the byte array. After reaching the end of the byte array + /// we write a 0 byte. Only write 0 byte if the byte array is empty. pub fn bytes(&mut self, x: &[u8]) -> Result<&mut Self, Error> { // use filler to write current buffer so bits used gets reset self.filler(); @@ -71,11 +73,12 @@ impl Encoder { self.byte_array(x) } - /// Encode a byte array in a byte aligned buffer. Throws exception if any bits for the current byte were used. - /// Writes byte array length up to 255 - /// Following that it writes the next 255 bytes from the array. - /// We repeat writing length up to 255 and the next 255 bytes until we reach the end of the byte array. - /// After reaching the end of the buffer we write a 0 byte. Only write 0 if the byte array is empty. + /// Encode a byte array in a byte aligned buffer. Throws exception if any + /// bits for the current byte were used. Writes byte array length up to + /// 255 Following that it writes the next 255 bytes from the array. + /// We repeat writing length up to 255 and the next 255 bytes until we reach + /// the end of the byte array. After reaching the end of the buffer we + /// write a 0 byte. Only write 0 if the byte array is empty. pub fn byte_array(&mut self, arr: &[u8]) -> Result<&mut Self, Error> { if self.used_bits != 0 { return Err(Error::BufferNotByteAligned); @@ -88,9 +91,11 @@ impl Encoder { /// Encode an integer of any size. /// This is byte alignment agnostic. - /// First we use zigzag once to double the number and encode the negative sign as the least significant bit. - /// Next we encode the 7 least significant bits of the unsigned integer. If the number is greater than - /// 127 we encode a leading 1 followed by repeating the encoding above for the next 7 bits and so on. + /// First we use zigzag once to double the number and encode the negative + /// sign as the least significant bit. Next we encode the 7 least + /// significant bits of the unsigned integer. If the number is greater than + /// 127 we encode a leading 1 followed by repeating the encoding above for + /// the next 7 bits and so on. pub fn integer(&mut self, i: isize) -> &mut Self { let i = zigzag::to_usize(i); @@ -101,9 +106,11 @@ impl Encoder { /// Encode an integer of 128 bits size. /// This is byte alignment agnostic. - /// First we use zigzag once to double the number and encode the negative sign as the least significant bit. - /// Next we encode the 7 least significant bits of the unsigned integer. If the number is greater than - /// 127 we encode a leading 1 followed by repeating the encoding above for the next 7 bits and so on. + /// First we use zigzag once to double the number and encode the negative + /// sign as the least significant bit. Next we encode the 7 least + /// significant bits of the unsigned integer. If the number is greater than + /// 127 we encode a leading 1 followed by repeating the encoding above for + /// the next 7 bits and so on. pub fn big_integer(&mut self, i: i128) -> &mut Self { let i = zigzag::to_u128(i); @@ -114,8 +121,9 @@ impl Encoder { /// Encode a char of 32 bits. /// This is byte alignment agnostic. - /// We encode the 7 least significant bits of the unsigned byte. If the char value is greater than - /// 127 we encode a leading 1 followed by repeating the above for the next 7 bits and so on. + /// We encode the 7 least significant bits of the unsigned byte. If the char + /// value is greater than 127 we encode a leading 1 followed by + /// repeating the above for the next 7 bits and so on. pub fn char(&mut self, c: char) -> &mut Self { self.word(c as usize); @@ -136,17 +144,19 @@ impl Encoder { /// Encode a string. /// Convert to byte array and then use byte array encoding. - /// Uses filler to byte align the buffer, then writes byte array length up to 255. - /// Following that it writes the next 255 bytes from the array. - /// After reaching the end of the buffer we write a 0 byte. Only write 0 byte if the byte array is empty. + /// Uses filler to byte align the buffer, then writes byte array length up + /// to 255. Following that it writes the next 255 bytes from the array. + /// After reaching the end of the buffer we write a 0 byte. Only write 0 + /// byte if the byte array is empty. pub fn utf8(&mut self, s: &str) -> Result<&mut Self, Error> { self.bytes(s.as_bytes()) } /// Encode a unsigned integer of any size. /// This is byte alignment agnostic. - /// We encode the 7 least significant bits of the unsigned byte. If the char value is greater than - /// 127 we encode a leading 1 followed by repeating the above for the next 7 bits and so on. + /// We encode the 7 least significant bits of the unsigned byte. If the char + /// value is greater than 127 we encode a leading 1 followed by + /// repeating the above for the next 7 bits and so on. pub fn word(&mut self, c: usize) -> &mut Self { let mut d = c; loop { @@ -168,8 +178,9 @@ impl Encoder { /// Encode a unsigned integer of 128 bits size. /// This is byte alignment agnostic. - /// We encode the 7 least significant bits of the unsigned byte. If the char value is greater than - /// 127 we encode a leading 1 followed by repeating the above for the next 7 bits and so on. + /// We encode the 7 least significant bits of the unsigned byte. If the char + /// value is greater than 127 we encode a leading 1 followed by + /// repeating the above for the next 7 bits and so on. pub fn big_word(&mut self, c: u128) -> &mut Self { let mut d = c; loop { @@ -191,8 +202,9 @@ impl Encoder { /// Encode a list of bytes with a function /// This is byte alignment agnostic. - /// If there are bytes in a list then write 1 bit followed by the functions encoding. - /// After the last item write a 0 bit. If the list is empty only encode a 0 bit. + /// If there are bytes in a list then write 1 bit followed by the functions + /// encoding. After the last item write a 0 bit. If the list is empty + /// only encode a 0 bit. pub fn encode_list_with( &mut self, list: &[T], @@ -209,10 +221,11 @@ impl Encoder { } /// Encodes up to 8 bits of information and is byte alignment agnostic. - /// Uses unused bits in the current byte to write out the passed in byte value. - /// Overflows to the most significant digits of the next byte if number of bits to use is greater than unused bits. - /// Expects that number of bits to use is greater than or equal to required bits by the value. - /// The param num_bits is i64 to match unused_bits type. + /// Uses unused bits in the current byte to write out the passed in byte + /// value. Overflows to the most significant digits of the next byte if + /// number of bits to use is greater than unused bits. Expects that + /// number of bits to use is greater than or equal to required bits by the + /// value. The param num_bits is i64 to match unused_bits type. pub fn bits(&mut self, num_bits: i64, val: u8) -> &mut Self { match (num_bits, val) { (1, 0) => self.zero(), @@ -237,13 +250,13 @@ impl Encoder { self.used_bits += num_bits; let unused_bits = 8 - self.used_bits; match unused_bits { - x if x > 0 => { - self.current_byte |= val << x; - } - x if x == 0 => { + 0 => { self.current_byte |= val; self.next_word(); } + x if x > 0 => { + self.current_byte |= val << x; + } x => { let used = -x; self.current_byte |= val >> used; @@ -289,8 +302,9 @@ impl Encoder { } } /// Write out byte regardless of current buffer alignment. - /// Write most significant bits in remaining unused bits for the current byte, - /// then write out the remaining bits at the beginning of the next byte. + /// Write most significant bits in remaining unused bits for the current + /// byte, then write out the remaining bits at the beginning of the next + /// byte. fn byte_unaligned(&mut self, x: u8) { let x_shift = self.current_byte | (x >> self.used_bits); self.buffer.push(x_shift); @@ -298,8 +312,9 @@ impl Encoder { self.current_byte = x << (8 - self.used_bits); } - /// Write the current byte out to the buffer and begin next byte to write out. - /// Add current byte to the buffer and set current byte and used bits to 0. + /// Write the current byte out to the buffer and begin next byte to write + /// out. Add current byte to the buffer and set current byte and used + /// bits to 0. fn next_word(&mut self) { self.buffer.push(self.current_byte); @@ -309,8 +324,8 @@ impl Encoder { /// Writes byte array length up to 255 /// Following that it writes the next 255 bytes from the array. - /// After reaching the end of the buffer we write a 0 byte. Only write 0 if the byte array is empty. - /// This is byte alignment agnostic. + /// After reaching the end of the buffer we write a 0 byte. Only write 0 if + /// the byte array is empty. This is byte alignment agnostic. fn write_blk(&mut self, arr: &[u8]) { let chunks = arr.chunks(255); diff --git a/pallas-network/src/miniprotocols/localstate/server.rs b/pallas-network/src/miniprotocols/localstate/server.rs index db5ed473..32f7fe83 100644 --- a/pallas-network/src/miniprotocols/localstate/server.rs +++ b/pallas-network/src/miniprotocols/localstate/server.rs @@ -47,11 +47,7 @@ impl GenericServer { } fn has_agency(&self) -> bool { - match self.state() { - State::Acquiring => true, - State::Querying => true, - _ => false, - } + matches!(self.state(), State::Acquiring | State::Querying) } fn assert_agency_is_ours(&self) -> Result<(), Error> { diff --git a/pallas-network/tests/protocols.rs b/pallas-network/tests/protocols.rs index d37e2b8a..8c129fd5 100644 --- a/pallas-network/tests/protocols.rs +++ b/pallas-network/tests/protocols.rs @@ -6,17 +6,14 @@ use pallas_codec::utils::AnyCbor; use pallas_network::facades::{NodeClient, PeerClient, PeerServer}; use pallas_network::miniprotocols::blockfetch::BlockRequest; use pallas_network::miniprotocols::chainsync::{ClientRequest, HeaderContent, Tip}; -use pallas_network::miniprotocols::handshake::n2c; use pallas_network::miniprotocols::handshake::n2n::VersionData; -use pallas_network::miniprotocols::localstate::{ClientAcquireRequest, ClientQueryRequest}; +use pallas_network::miniprotocols::localstate::ClientQueryRequest; use pallas_network::miniprotocols::{ blockfetch, chainsync::{self, NextResponse}, Point, }; -use pallas_network::miniprotocols::{ - handshake, localstate, PROTOCOL_N2C_HANDSHAKE, PROTOCOL_N2C_STATE_QUERY, -}; +use pallas_network::miniprotocols::{handshake, localstate}; use pallas_network::multiplexer::{Bearer, Plexer}; use std::path::Path; use tokio::net::{TcpListener, UnixListener}; diff --git a/pallas-primitives/src/conway/model.rs b/pallas-primitives/src/conway/model.rs index cef2a31a..385955cf 100644 --- a/pallas-primitives/src/conway/model.rs +++ b/pallas-primitives/src/conway/model.rs @@ -841,7 +841,7 @@ impl minicbor::Encode for ProposalProcedure { ) -> Result<(), minicbor::encode::Error> { e.array(4)?; - e.encode_with(&self.deposit, ctx)?; + e.encode_with(self.deposit, ctx)?; e.encode_with(&self.reward_account, ctx)?; e.encode_with(&self.gov_action, ctx)?; e.encode_with(&self.anchor, ctx)?; @@ -852,7 +852,7 @@ impl minicbor::Encode for ProposalProcedure { #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] pub enum GovAction { - ParameterChange(Option, ProtocolParamUpdate), + ParameterChange(Option, Box), HardForkInitiation(Option, Vec), TreasuryWithdrawals(KeyValuePairs), NoConfidence(Option), @@ -1080,7 +1080,7 @@ impl minicbor::Encode for Anchor { e.array(2)?; e.encode_with(&self.0, ctx)?; - e.encode_with(&self.1, ctx)?; + e.encode_with(self.1, ctx)?; Ok(()) } @@ -1105,8 +1105,8 @@ impl minicbor::Encode for GovActionId { ) -> Result<(), minicbor::encode::Error> { e.array(2)?; - e.encode_with(&self.0, ctx)?; - e.encode_with(&self.1, ctx)?; + e.encode_with(self.0, ctx)?; + e.encode_with(self.1, ctx)?; Ok(()) } @@ -1570,7 +1570,8 @@ mod tests { // fn fragments_decoding() { // // peculiar array of outputs used in an hydra transaction // let bytes = hex::decode(hex).unwrap(); - // let outputs = Vec::::decode_fragment(&bytes).unwrap(); + // let outputs = + // Vec::::decode_fragment(&bytes).unwrap(); // // dbg!(outputs); // diff --git a/pallas-rolldb/src/wal/store.rs b/pallas-rolldb/src/wal/store.rs index 8193bbd0..1a7cd92f 100644 --- a/pallas-rolldb/src/wal/store.rs +++ b/pallas-rolldb/src/wal/store.rs @@ -131,7 +131,7 @@ impl<'a> RollBatch<'a> { fn stage_append(&mut self, log: Log) { let new_seq = self.2 + 1; - WalKV::stage_upsert(&self.0, DBInt(new_seq), DBSerde(log), &mut self.1); + WalKV::stage_upsert(self.0, DBInt(new_seq), DBSerde(log), &mut self.1); self.2 = new_seq; } @@ -175,7 +175,7 @@ impl Store { hash: BlockHash, body: BlockBody, ) -> Result<(), Error> { - let mut batch = RollBatch::new(&mut self.db, self.wal_seq); + let mut batch = RollBatch::new(&self.db, self.wal_seq); batch.stage_append(Log::Apply(slot, hash, body)); diff --git a/pallas-traverse/src/tx.rs b/pallas-traverse/src/tx.rs index 10cc5d4a..3506ecb6 100644 --- a/pallas-traverse/src/tx.rs +++ b/pallas-traverse/src/tx.rs @@ -9,8 +9,8 @@ use pallas_primitives::{ }; use crate::{ - Era, MultiEraCert, MultiEraInput, MultiEraMeta, MultiEraOutput, MultiEraPolicyAssets, - MultiEraSigners, MultiEraTx, MultiEraUpdate, MultiEraWithdrawals, OriginalHash, Error + Era, Error, MultiEraCert, MultiEraInput, MultiEraMeta, MultiEraOutput, MultiEraPolicyAssets, + MultiEraSigners, MultiEraTx, MultiEraUpdate, MultiEraWithdrawals, OriginalHash, }; impl<'b> MultiEraTx<'b> { @@ -66,16 +66,19 @@ impl<'b> MultiEraTx<'b> { /// successful pub fn decode(cbor: &'b [u8]) -> Result { if let Ok(tx) = minicbor::decode(cbor) { - return Ok(MultiEraTx::Conway(Box::new(Cow::Owned(tx)))) + return Ok(MultiEraTx::Conway(Box::new(Cow::Owned(tx)))); } if let Ok(tx) = minicbor::decode(cbor) { - return Ok(MultiEraTx::Babbage(Box::new(Cow::Owned(tx)))) + return Ok(MultiEraTx::Babbage(Box::new(Cow::Owned(tx)))); } if let Ok(tx) = minicbor::decode(cbor) { // Shelley/Allegra/Mary/Alonzo will all decode to Alonzo - return Ok(MultiEraTx::AlonzoCompatible(Box::new(Cow::Owned(tx)), Era::Alonzo)) + return Ok(MultiEraTx::AlonzoCompatible( + Box::new(Cow::Owned(tx)), + Era::Alonzo, + )); } if let Ok(tx) = minicbor::decode(cbor) {