Skip to content

Commit

Permalink
Doc
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Depierrepont <[email protected]>
  • Loading branch information
toorop committed May 20, 2014
1 parent 944aa7c commit 711303a
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 45 deletions.
4 changes: 2 additions & 2 deletions bitcoind.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (b *Bitcoind) GetBestBlockhash() (bestBlockHash string, err error) {
}

// GetBlock returns information about the block with the given hash.
func (b *Bitcoind) GetBlock(blockHash string) (block block, err error) {
func (b *Bitcoind) GetBlock(blockHash string) (block Block, err error) {
r, err := b.client.call("getblock", []string{blockHash})
if err = handleError(err, &r); err != nil {
return
Expand Down Expand Up @@ -193,7 +193,7 @@ func (b *Bitcoind) GetHashesPerSec() (hashpersec float64, err error) {
}

// GetInfo return result of "getinfo" command (Amazing !)
func (b *Bitcoind) GetInfo() (i info, err error) {
func (b *Bitcoind) GetInfo() (i Info, err error) {
r, err := b.client.call("getinfo", nil)
if err = handleError(err, &r); err != nil {
return
Expand Down
6 changes: 4 additions & 2 deletions bitcoind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ var _ = Describe("Bitcoind", func() {
Expect(err).NotTo(HaveOccurred())
})
It("should return", func() {
Expect(bestblockhash).Should(Equal(block{
Expect(bestblockhash).Should(Equal(Block{
Hash: "00000000000000003f8d1861d035e44d4297c49bd2517dc0a44ad73c7091926c",
Confirmations: 503,
Size: 348678,
Expand Down Expand Up @@ -912,7 +912,7 @@ var _ = Describe("Bitcoind", func() {
Expect(err).NotTo(HaveOccurred())
})
It("should return", func() {
Expect(rinfo).Should(Equal(info{
Expect(rinfo).Should(Equal(Info{
Version: 99900,
Protocolversion: 70002,
Walletversion: 60000,
Expand All @@ -924,6 +924,8 @@ var _ = Describe("Bitcoind", func() {
Difficulty: 8.8534163091278e+09,
Testnet: false,
Keypoololdest: 1399795067,
KeypoolSize: 101,
UnlockedUntil: 1400519823,
Paytxfee: 0,
Relayfee: 1e-05,
Errors: "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications",
Expand Down
57 changes: 42 additions & 15 deletions block.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
package bitcoind

// Represents a block
type block struct {
Hash string `json:"hash"`
Confirmations uint64 `json:"confirmations"`
Size uint64 `json:"size"`
Height uint64 `json:"height"`
Version uint64 `json:"version"`
Merkleroot string `json:"merkleroot"`
Tx []string `json:"tx"`
Time int64 `json:"time"`
Nonce uint64 `json:"nonce"`
Bits string `json:"bits"`
Difficulty float64 `json:"difficulty"`
Chainwork string `json:"chainwork"`
Previousblockhash string `json:"previousblockhash"`
Nextblockhash string `json:"nextblockhash"`
type Block struct {
// The block hash
Hash string `json:"hash"`

// The number of confirmations
Confirmations uint64 `json:"confirmations"`

// The block size
Size uint64 `json:"size"`

// The block height or index
Height uint64 `json:"height"`

// The block version
Version uint32 `json:"version"`

// The merkle root
Merkleroot string `json:"merkleroot"`

// Slice on transaction ids
Tx []string `json:"tx"`

// The block time in seconds since epoch (Jan 1 1970 GMT)
Time int64 `json:"time"`

// The nonce
Nonce uint64 `json:"nonce"`

// The bits
Bits string `json:"bits"`

// The difficulty
Difficulty float64 `json:"difficulty"`

// Total amount of work in active chain, in hexadecimal
Chainwork string `json:"chainwork,omitempty"`

// The hash of the previous block
Previousblockhash string `json:"previousblockhash"`

// The hash of the next block
Nextblockhash string `json:"nextblockhash"`
}
64 changes: 49 additions & 15 deletions info.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,52 @@
package bitcoind

type info struct {
Version uint32 `json:"version"`
Protocolversion uint32 `json:"protocolversion"`
Walletversion uint32 `json:"walletversion"`
Balance float64 `json:"balance"`
Blocks uint32 `json:"blocks"`
Timeoffset uint32 `json:"timeoffset"`
Connections uint32 `json:"connections"`
Proxy string `json:"proxy"`
Difficulty float64 `json:"difficulty"`
Testnet bool `json:"testnet"`
Keypoololdest uint64 `json:"keypoololdest"`
Paytxfee float64 `json:"paytxfee"`
Relayfee float64 `json:"relayfee"`
Errors string `json:"errors"`
// An Info represent a response to getmininginfo
type Info struct {
// The server version
Version uint32 `json:"version"`

// The protocol version
Protocolversion uint32 `json:"protocolversion"`

// The wallet version
Walletversion uint32 `json:"walletversion"`

// The total bitcoin balance of the wallet
Balance float64 `json:"balance"`

// The current number of blocks processed in the server
Blocks uint32 `json:"blocks"`

// The time offset
Timeoffset uint32 `json:"timeoffset"`

// The number of connections
Connections uint32 `json:"connections"`

// Tthe proxy used by the server
Proxy string `json:"proxy,omitempty"`

// Tthe current difficulty
Difficulty float64 `json:"difficulty"`

// If the server is using testnet or not
Testnet bool `json:"testnet"`

// The timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool
Keypoololdest uint64 `json:"keypoololdest"`

// How many new keys are pre-generated
KeypoolSize uint32 `json:"keypoolsize,omitempty"`

// The timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked
UnlockedUntil int64 `json:"unlocked_until,omitempty"`

// the transaction fee set in btc/kb
Paytxfee float64 `json:"paytxfee"`

// Minimum relay fee for non-free transactions in btc/kb
Relayfee float64 `json:"relayfee"`

// Any error messages
Errors string `json:"errors"`
}
42 changes: 31 additions & 11 deletions miningInfo.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
package bitcoind

// A MiningInfo represents a mininginfo response
type MiningInfo struct {
// The current block
Blocks uint64 `json:"block"`
Blocks uint64 `json:"blocks"`

// The last block size
CurrentBlocksize uint64 `json:"currentblocksize"`
CurrentBlockTx uint64 `json:"currentblocktx"` // The last block transaction
Difficulty float64 `json:"difficulty"`
Errors string `json:"errors"`
GenProcLimit int32 `json:"genproclimit"`
NetworkHashps uint64 `json:"networkhashps"`
PooledtTx uint64 `json:"pooledtx"`
Testnet bool `json:"testnet"`
Generate bool `json:"generate"`
HashesPersec uint64 `json:"hashespersec"`
CurrentBlocksize uint64 `json:"currentblocksize"`

// The last block transaction
CurrentBlockTx uint64 `json:"currentblocktx"`

// The current difficulty
Difficulty float64 `json:"difficulty"`

// Current errors
Errors string `json:"errors"`

// The processor limit for generation. -1 if no generation. (see getgenerate or setgenerate calls)
GenProcLimit int32 `json:"genproclimit"`

// The size of the mem pool
PooledtTx uint64 `json:"pooledtx"`

// If using testnet or not
Testnet bool `json:"testnet"`

// If the generation is on or off (see getgenerate or setgenerate calls)
Generate bool `json:"generate"`

// The network hashrate
NetworkHashps uint64 `json:"networkhashps"`

// Node hashrate
HashesPersec uint64 `json:"hashespersec"`
}

0 comments on commit 711303a

Please sign in to comment.