packages feed

network-bitcoin 1.7.2 → 1.8.0

raw patch · 3 files changed

+16/−4 lines, 3 files

Files

network-bitcoin.cabal view
@@ -1,5 +1,5 @@ Name:                network-bitcoin-Version:             1.7.2+Version:             1.8.0 Synopsis:            An interface to bitcoind. Description:     This can be used to send Bitcoins, query balances, etc.  It
src/Network/Bitcoin/Internal.hs view
@@ -17,6 +17,7 @@                                 , callApi                                 , getClient                                 , Nil(..)+                                , NilOrArray(..)                                 , tj                                 , tjm                                 , tja@@ -122,6 +123,13 @@     parseJSON Null = return $ Nil ()     parseJSON x    = fail $ "\"null\" was expected, but " ++ show x ++ " was recieved." +-- | Used to parse "null" or [HexString]+data NilOrArray = NilOrArray {unArr :: Maybe [HexString]}++instance FromJSON NilOrArray where+    parseJSON Null = return $ NilOrArray Nothing+    parseJSON a@(Array _) = liftM NilOrArray $ parseJSON a+    parseJSON x = fail $ "Expected \"null\" or array, but " ++ show x ++ " was recieved."  -- | A handy shortcut for toJSON, because I'm lazy. tj :: ToJSON a => a -> Value
src/Network/Bitcoin/Mining.hs view
@@ -40,17 +40,21 @@ getGenerate client = callApi client "getgenerate" []  -- | Controls whether or not bitcoind is generating bitcoins.+--   If bitcoind runs in regtest mode the number of generated hashes is returned.+--   See https://bitcoin.org/en/developer-reference#setgenerate for more details. setGenerate :: Client -- ^ bitcoind RPC client             -> Bool -- ^ Turn it on, or turn it off?             -> Maybe Int -- ^ Generation is limited to this number of                          --   processors. Set it to Nothing to keep the value                          --   at what it was before, Just -1 to use all                          --   available cores, and any other value to limit it.-            -> IO ()+                         --   If bitcoind runs in regtest mode instead of the number of processors,+                         --   this specifies the number of hashes to generate.+            -> IO (Maybe [HexString]) setGenerate client onOff Nothing =-    unNil <$> callApi client "setgenerate" [ tj onOff ]+    unArr <$> callApi client "setgenerate" [ tj onOff ] setGenerate client onOff (Just limit) =-    unNil <$> callApi client "setgenerate" [ tj onOff, tj limit ]+    unArr <$> callApi client "setgenerate" [ tj onOff, tj limit ]  -- | Returns a recent hashes per second performance measurement while --   generating.