{-# LANGUAGE DeriveGeneric #-}
module Data.Snowchecked.Types
( module Data.Snowchecked.Types )
where
import Control.Concurrent.MVar
import Control.DeepSeq (NFData)
import Data.Default
import Data.WideWord.Word256
import Data.Word
import GHC.Generics (Generic)
data SnowcheckedConfig = SnowcheckedConfig
{ SnowcheckedConfig -> Word8
confTimeBits :: Word8
, SnowcheckedConfig -> Word8
confCountBits :: Word8
, SnowcheckedConfig -> Word8
confNodeBits :: Word8
, SnowcheckedConfig -> Word8
confCheckBits :: Word8
} deriving (SnowcheckedConfig -> SnowcheckedConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
$c/= :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
== :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
$c== :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
Eq, Int -> SnowcheckedConfig -> ShowS
[SnowcheckedConfig] -> ShowS
SnowcheckedConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnowcheckedConfig] -> ShowS
$cshowList :: [SnowcheckedConfig] -> ShowS
show :: SnowcheckedConfig -> String
$cshow :: SnowcheckedConfig -> String
showsPrec :: Int -> SnowcheckedConfig -> ShowS
$cshowsPrec :: Int -> SnowcheckedConfig -> ShowS
Show, forall x. Rep SnowcheckedConfig x -> SnowcheckedConfig
forall x. SnowcheckedConfig -> Rep SnowcheckedConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnowcheckedConfig x -> SnowcheckedConfig
$cfrom :: forall x. SnowcheckedConfig -> Rep SnowcheckedConfig x
Generic, Eq SnowcheckedConfig
SnowcheckedConfig -> SnowcheckedConfig -> Bool
SnowcheckedConfig -> SnowcheckedConfig -> Ordering
SnowcheckedConfig -> SnowcheckedConfig -> SnowcheckedConfig
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SnowcheckedConfig -> SnowcheckedConfig -> SnowcheckedConfig
$cmin :: SnowcheckedConfig -> SnowcheckedConfig -> SnowcheckedConfig
max :: SnowcheckedConfig -> SnowcheckedConfig -> SnowcheckedConfig
$cmax :: SnowcheckedConfig -> SnowcheckedConfig -> SnowcheckedConfig
>= :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
$c>= :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
> :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
$c> :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
<= :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
$c<= :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
< :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
$c< :: SnowcheckedConfig -> SnowcheckedConfig -> Bool
compare :: SnowcheckedConfig -> SnowcheckedConfig -> Ordering
$ccompare :: SnowcheckedConfig -> SnowcheckedConfig -> Ordering
Ord)
instance NFData SnowcheckedConfig
instance Default SnowcheckedConfig where
def :: SnowcheckedConfig
def = SnowcheckedConfig
{ confTimeBits :: Word8
confTimeBits = Word8
40
, confCountBits :: Word8
confCountBits = Word8
10
, confNodeBits :: Word8
confNodeBits = Word8
8
, confCheckBits :: Word8
confCheckBits = Word8
6
}
newtype SnowcheckedGen = SnowcheckedGen { SnowcheckedGen -> MVar Flake
genLastFlake :: MVar Flake }
data Flake = Flake
{ Flake -> Word256
flakeTime :: Word256
, Flake -> Word256
flakeCount :: Word256
, Flake -> Word256
flakeNodeId :: Word256
, Flake -> SnowcheckedConfig
flakeConfig :: SnowcheckedConfig
} deriving (Flake -> Flake -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Flake -> Flake -> Bool
$c/= :: Flake -> Flake -> Bool
== :: Flake -> Flake -> Bool
$c== :: Flake -> Flake -> Bool
Eq,Int -> Flake -> ShowS
[Flake] -> ShowS
Flake -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Flake] -> ShowS
$cshowList :: [Flake] -> ShowS
show :: Flake -> String
$cshow :: Flake -> String
showsPrec :: Int -> Flake -> ShowS
$cshowsPrec :: Int -> Flake -> ShowS
Show,Eq Flake
Flake -> Flake -> Bool
Flake -> Flake -> Ordering
Flake -> Flake -> Flake
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Flake -> Flake -> Flake
$cmin :: Flake -> Flake -> Flake
max :: Flake -> Flake -> Flake
$cmax :: Flake -> Flake -> Flake
>= :: Flake -> Flake -> Bool
$c>= :: Flake -> Flake -> Bool
> :: Flake -> Flake -> Bool
$c> :: Flake -> Flake -> Bool
<= :: Flake -> Flake -> Bool
$c<= :: Flake -> Flake -> Bool
< :: Flake -> Flake -> Bool
$c< :: Flake -> Flake -> Bool
compare :: Flake -> Flake -> Ordering
$ccompare :: Flake -> Flake -> Ordering
Ord,forall x. Rep Flake x -> Flake
forall x. Flake -> Rep Flake x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Flake x -> Flake
$cfrom :: forall x. Flake -> Rep Flake x
Generic)
instance NFData Flake