Struct grin_core::core::transaction::FeeFields

source ·
pub struct FeeFields(/* private fields */);
Expand description

Fee fields as in fix-fees RFC: { future_use: 20, fee_shift: 4, fee: 40 }

Implementations§

source§

impl FeeFields

source

pub const FEE_SHIFT_BITS: u32 = 4u32

Fee shifts are limited to 4 bits

source

pub const FEE_SHIFT_MASK: u64 = 15u64

Used to extract fee_shift field

source

pub fn zero() -> Self

Create a zero FeeFields with 0 fee and 0 fee_shift

source

pub fn new(fee_shift: u64, fee: u64) -> Result<Self, Error>

Create a new FeeFields from the provided shift and fee Checks both are valid (in range)

source

pub fn fee_shift(&self) -> u8

Extract fee_shift field

source

pub fn fee(&self) -> u64

Extract fee field

source

pub fn as_opt(&self) -> Option<Self>

Turn a zero FeeField into a None, any other value into a Some. We need this because a zero FeeField cannot be deserialized.

source

pub fn is_zero(&self) -> bool

Check if the FeeFields is set to zero

Trait Implementations§

source§

impl Clone for FeeFields

source§

fn clone(&self) -> FeeFields

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FeeFields

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for FeeFields

source§

fn deserialize<D>(deserializer: D) -> Result<FeeFields, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for FeeFields

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<FeeFields> for u64

source§

fn from(fee_fields: FeeFields) -> Self

Converts to this type from the input type.
source§

impl From<u32> for FeeFields

Conversion from a 32-bit fee to a FeeFields with 0 fee_shift For use exclusively in tests with constant fees

source§

fn from(fee: u32) -> Self

Converts to this type from the input type.
source§

impl PartialEq for FeeFields

source§

fn eq(&self, other: &FeeFields) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Readable for FeeFields

source§

fn read<R: Reader>(reader: &mut R) -> Result<Self, Error>

Reads the data necessary to this Readable from the provided reader
source§

impl Serialize for FeeFields

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<u64> for FeeFields

Conversion from a valid fee to a FeeFields with 0 fee_shift The valid fee range is 1..FEE_MASK

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(fee: u64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Writeable for FeeFields

source§

fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>

Write the data held by this Writeable to the provided writer
source§

impl Copy for FeeFields

source§

impl DefaultHashable for FeeFields

source§

impl StructuralPartialEq for FeeFields

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneAny for T
where T: Any + Clone,

source§

fn clone_any(&self) -> Box<dyn CloneAny>

source§

fn clone_any_send(&self) -> Box<dyn CloneAny + Send>
where T: Send,

source§

fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync>
where T: Sync,

source§

fn clone_any_send_sync(&self) -> Box<dyn CloneAny + Send + Sync>
where T: Send + Sync,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<D> Hashed for D
where D: DefaultHashable,

source§

fn hash(&self) -> Hash

Obtain the hash of the object
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> PMMRIndexHashable for T
where T: DefaultHashable,

source§

fn hash_with_index(&self, index: u64) -> Hash

Hash with a given index
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<H> ShortIdentifiable for H
where H: Hashed,

source§

fn short_id(&self, hash: &Hash, nonce: u64) -> ShortId

Generate a short_id via the following -

  • extract k0/k1 from block_hash hashed with the nonce (first two u64 values) * initialize a siphasher24 with k0/k1
    • self.hash() passing in the siphasher24 instance
    • drop the 2 most significant bytes (to return a 6 byte short_id)
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DebugAny for T
where T: Any + Debug,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> UnsafeAny for T
where T: Any,