Jsonrpc over http - connecting to bitcoind

polaris · · 1252 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi, as an example I want to run the method &#34;getdifficulty&#34; on bitcoind and show the result.</p> <p>What&#39;s the cleanest way to use json-rpc over http? (without over complicating things) (and why isn&#39;t net/rpc/jsonrpc not working?)</p> <p>I&#39;ve already done it using <a href="https://github.com/btcsuite/btcrpcclient" rel="nofollow">btcrpcclient</a> and I also tried <a href="http://stackoverflow.com/questions/8918455/how-to-properly-call-json-rpc-in-go" rel="nofollow">this way</a>.</p> <p>I&#39;m trying to do it without btcrpcclient because I wanted to know how much overhead that library add. So I&#39;m reinventing the wheel a bit to avoid using such a big library when I&#39;ll only need to use a few methods.</p> <p>With the SO answer, I wanted to clean up the code a bit, to avoid giving the address every time I thought about making a client. but seems like the rpc package already do that kind of client, so I tried to do the same thing but with a custom codec but couldn&#39;t really make something that works.</p> <hr/>**评论:**<br/><br/>Incubuss: <pre><p>I made a really basic JSON RPC over HTTP &#34;library&#34; a while ago to test something I was working on. I said &#34;library&#34; because it&#39;s not a library, it doesn&#39;t have any tests, and the code probably has some issues, however it demonstrates how easy it is to do it yourself: <a href="https://github.com/JamesMcMinn/json-rpc-http/blob/master/rcp.go" rel="nofollow">https://github.com/JamesMcMinn/json-rpc-http/blob/master/rcp.go</a></p></pre>Simpfally: <pre><p>After posting I actually had some free time to try what I said. So I used a client struct. My code was a bit similar to yours but without the closure. </p> <p>Finally I removed the struct part and simply did a function to make the request and two functions for the two methods I&#39;m gonna use on bitcoind. More straightforward even if it&#39;s less expendable.</p> <p>I&#39;m gonna do some benchmark now</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1252 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传