From 1db0eb4fec131679d4293b74c2913c36c4e98910 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sun, 29 Jun 2014 16:36:41 -0500 Subject: [PATCH] Update for recent btcjson changes. This commit updates the types to match the recent changes to the btcjson result types. --- rpcserver.go | 16 ++++++++-------- server.go | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index ea1ef813..497b550a 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -828,7 +828,7 @@ func createVoutList(mtx *btcwire.MsgTx, net *btcnet.Params) ([]btcjson.Vout, err // it anyways. scriptClass, addrs, reqSigs, _ := btcscript.ExtractPkScriptAddrs(v.PkScript, net) voutList[i].ScriptPubKey.Type = scriptClass.String() - voutList[i].ScriptPubKey.ReqSigs = reqSigs + voutList[i].ScriptPubKey.ReqSigs = int32(reqSigs) if addrs == nil { voutList[i].ScriptPubKey.Addresses = nil @@ -973,7 +973,7 @@ func handleDecodeScript(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{} // Generate and return the reply. reply := btcjson.DecodeScriptResult{ Asm: disbuf, - ReqSigs: reqSigs, + ReqSigs: int32(reqSigs), Type: scriptClass.String(), Addresses: addresses, P2sh: p2sh.EncodeAddress(), @@ -1142,7 +1142,7 @@ func handleGetBlock(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (i Time: blockHeader.Timestamp.Unix(), Confirmations: uint64(1 + maxidx - idx), Height: idx, - Size: len(buf), + Size: int32(len(buf)), Bits: strconv.FormatInt(int64(blockHeader.Bits), 16), Difficulty: getDifficultyRatio(blockHeader.Bits), } @@ -1262,9 +1262,9 @@ func handleGetInfo(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (in } ret := &btcjson.InfoResult{ - Version: int(1000000*appMajor + 10000*appMinor + 100*appPatch), - ProtocolVersion: int(maxProtocolVersion), - Blocks: int(height), + Version: int32(1000000*appMajor + 10000*appMinor + 100*appPatch), + ProtocolVersion: int32(maxProtocolVersion), + Blocks: int32(height), TimeOffset: 0, Connections: s.server.ConnectedCount(), Proxy: cfg.Proxy, @@ -1327,7 +1327,7 @@ func handleGetMiningInfo(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{ CurrentBlockTx: uint64(len(block.MsgBlock().Transactions)), Difficulty: getDifficultyRatio(block.MsgBlock().Header.Bits), Generate: s.server.cpuMiner.IsMining(), - GenProcLimit: int(s.server.cpuMiner.NumWorkers()), + GenProcLimit: s.server.cpuMiner.NumWorkers(), HashesPerSec: int64(s.server.cpuMiner.HashesPerSecond()), NetworkHashPS: networkHashesPerSec, PooledTx: uint64(s.server.txMemPool.Count()), @@ -1449,7 +1449,7 @@ func handleGetRawMempool(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{ result := make(map[string]*btcjson.GetRawMempoolResult, len(descs)) for _, desc := range descs { mpd := &btcjson.GetRawMempoolResult{ - Size: desc.Tx.MsgTx().SerializeSize(), + Size: int32(desc.Tx.MsgTx().SerializeSize()), Fee: float64(desc.Fee) / float64(btcutil.SatoshiPerBitcoin), Time: desc.Added.Unix(), diff --git a/server.go b/server.go index 37a86064..7fb90a42 100644 --- a/server.go +++ b/server.go @@ -317,7 +317,7 @@ func (s *server) handleBroadcastMsg(state *peerState, bmsg *broadcastMsg) { } type getConnCountMsg struct { - reply chan int + reply chan int32 } type getPeerInfoMsg struct { @@ -344,7 +344,7 @@ type getAddedNodesMsg struct { func (s *server) handleQuery(querymsg interface{}, state *peerState) { switch msg := querymsg.(type) { case getConnCountMsg: - nconnected := 0 + nconnected := int32(0) state.forAllPeers(func(p *peer) { if p.Connected() { nconnected++ @@ -694,8 +694,8 @@ func (s *server) BroadcastMessage(msg btcwire.Message, exclPeers ...*peer) { } // ConnectedCount returns the number of currently connected peers. -func (s *server) ConnectedCount() int { - replyChan := make(chan int) +func (s *server) ConnectedCount() int32 { + replyChan := make(chan int32) s.query <- getConnCountMsg{reply: replyChan}