{-# LANGUAGE BangPatterns, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings #-} {-# OPTIONS_GHC -w #-} module Network.Haskoin.Store.ProtocolBuffers.Balance (Balance(..)) where import Prelude ((+), (/), (++), (.)) import qualified Prelude as Prelude' import qualified Data.Typeable as Prelude' import qualified GHC.Generics as Prelude' import qualified Data.Data as Prelude' import qualified Text.ProtocolBuffers.Header as P' data Balance = Balance{address :: !(P'.Utf8), confirmed :: !(P'.Word64), unconfirmed :: !(P'.Word64), utxo :: !(P'.Word64), received :: !(P'.Word64), txs :: !(P'.Word64)} deriving (Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data, Prelude'.Generic) instance P'.Mergeable Balance where mergeAppend (Balance x'1 x'2 x'3 x'4 x'5 x'6) (Balance y'1 y'2 y'3 y'4 y'5 y'6) = Balance (P'.mergeAppend x'1 y'1) (P'.mergeAppend x'2 y'2) (P'.mergeAppend x'3 y'3) (P'.mergeAppend x'4 y'4) (P'.mergeAppend x'5 y'5) (P'.mergeAppend x'6 y'6) instance P'.Default Balance where defaultValue = Balance P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue P'.defaultValue instance P'.Wire Balance where wireSize ft' self'@(Balance x'1 x'2 x'3 x'4 x'5 x'6) = case ft' of 10 -> calc'Size 11 -> P'.prependMessageSize calc'Size _ -> P'.wireSizeErr ft' self' where calc'Size = (P'.wireSizeReq 1 9 x'1 + P'.wireSizeReq 1 4 x'2 + P'.wireSizeReq 1 4 x'3 + P'.wireSizeReq 1 4 x'4 + P'.wireSizeReq 1 4 x'5 + P'.wireSizeReq 1 4 x'6) wirePutWithSize ft' self'@(Balance x'1 x'2 x'3 x'4 x'5 x'6) = case ft' of 10 -> put'Fields 11 -> put'FieldsSized _ -> P'.wirePutErr ft' self' where put'Fields = P'.sequencePutWithSize [P'.wirePutReqWithSize 2 9 x'1, P'.wirePutReqWithSize 8 4 x'2, P'.wirePutReqWithSize 16 4 x'3, P'.wirePutReqWithSize 24 4 x'4, P'.wirePutReqWithSize 32 4 x'5, P'.wirePutReqWithSize 40 4 x'6] put'FieldsSized = let size' = Prelude'.fst (P'.runPutM put'Fields) put'Size = do P'.putSize size' Prelude'.return (P'.size'WireSize size') in P'.sequencePutWithSize [put'Size, put'Fields] wireGet ft' = case ft' of 10 -> P'.getBareMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) 11 -> P'.getMessageWith (P'.catch'Unknown' P'.discardUnknown update'Self) _ -> P'.wireGetErr ft' where update'Self wire'Tag old'Self = case wire'Tag of 2 -> Prelude'.fmap (\ !new'Field -> old'Self{address = new'Field}) (P'.wireGet 9) 8 -> Prelude'.fmap (\ !new'Field -> old'Self{confirmed = new'Field}) (P'.wireGet 4) 16 -> Prelude'.fmap (\ !new'Field -> old'Self{unconfirmed = new'Field}) (P'.wireGet 4) 24 -> Prelude'.fmap (\ !new'Field -> old'Self{utxo = new'Field}) (P'.wireGet 4) 32 -> Prelude'.fmap (\ !new'Field -> old'Self{received = new'Field}) (P'.wireGet 4) 40 -> Prelude'.fmap (\ !new'Field -> old'Self{txs = new'Field}) (P'.wireGet 4) _ -> let (field'Number, wire'Type) = P'.splitWireTag wire'Tag in P'.unknown field'Number wire'Type old'Self instance P'.MessageAPI msg' (msg' -> Balance) Balance where getVal m' f' = f' m' instance P'.GPB Balance instance P'.ReflectDescriptor Balance where getMessageInfo _ = P'.GetMessageInfo (P'.fromDistinctAscList [2, 8, 16, 24, 32, 40]) (P'.fromDistinctAscList [2, 8, 16, 24, 32, 40]) reflectDescriptorInfo _ = Prelude'.read "DescriptorInfo {descName = ProtoName {protobufName = FIName \".ProtocolBuffers.Balance\", haskellPrefix = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule = [MName \"ProtocolBuffers\"], baseName = MName \"Balance\"}, descFilePath = [\"Network\",\"Haskoin\",\"Store\",\"ProtocolBuffers\",\"Balance.hs\"], isGroup = False, fields = fromList [FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Balance.address\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Balance\"], baseName' = FName \"address\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 0}, wireTag = WireTag {getWireTag = 2}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 9}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Balance.confirmed\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Balance\"], baseName' = FName \"confirmed\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 1}, wireTag = WireTag {getWireTag = 8}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 4}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Balance.unconfirmed\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Balance\"], baseName' = FName \"unconfirmed\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 2}, wireTag = WireTag {getWireTag = 16}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 4}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Balance.utxo\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Balance\"], baseName' = FName \"utxo\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 3}, wireTag = WireTag {getWireTag = 24}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 4}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Balance.received\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Balance\"], baseName' = FName \"received\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 4}, wireTag = WireTag {getWireTag = 32}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 4}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing},FieldInfo {fieldName = ProtoFName {protobufName' = FIName \".ProtocolBuffers.Balance.txs\", haskellPrefix' = [MName \"Network\",MName \"Haskoin\",MName \"Store\"], parentModule' = [MName \"ProtocolBuffers\",MName \"Balance\"], baseName' = FName \"txs\", baseNamePrefix' = \"\"}, fieldNumber = FieldId {getFieldId = 5}, wireTag = WireTag {getWireTag = 40}, packedTag = Nothing, wireTagLength = 1, isPacked = False, isRequired = True, canRepeat = False, mightPack = False, typeCode = FieldType {getFieldType = 4}, typeName = Nothing, hsRawDefault = Nothing, hsDefault = Nothing}], descOneofs = fromList [], keys = fromList [], extRanges = [], knownKeys = fromList [], storeUnknown = False, lazyFields = False, makeLenses = False, jsonInstances = False}" instance P'.TextType Balance where tellT = P'.tellSubMessage getT = P'.getSubMessage instance P'.TextMsg Balance where textPut msg = do P'.tellT "address" (address msg) P'.tellT "confirmed" (confirmed msg) P'.tellT "unconfirmed" (unconfirmed msg) P'.tellT "utxo" (utxo msg) P'.tellT "received" (received msg) P'.tellT "txs" (txs msg) textGet = do mods <- P'.sepEndBy (P'.choice [parse'address, parse'confirmed, parse'unconfirmed, parse'utxo, parse'received, parse'txs]) P'.spaces Prelude'.return (Prelude'.foldl (\ v f -> f v) P'.defaultValue mods) where parse'address = P'.try (do v <- P'.getT "address" Prelude'.return (\ o -> o{address = v})) parse'confirmed = P'.try (do v <- P'.getT "confirmed" Prelude'.return (\ o -> o{confirmed = v})) parse'unconfirmed = P'.try (do v <- P'.getT "unconfirmed" Prelude'.return (\ o -> o{unconfirmed = v})) parse'utxo = P'.try (do v <- P'.getT "utxo" Prelude'.return (\ o -> o{utxo = v})) parse'received = P'.try (do v <- P'.getT "received" Prelude'.return (\ o -> o{received = v})) parse'txs = P'.try (do v <- P'.getT "txs" Prelude'.return (\ o -> o{txs = v}))