Bitcoin Forum

Bitcoin => Project Development => Topic started by: pocesar on July 26, 2013, 02:20:35 PM



Title: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on July 26, 2013, 02:20:35 PM
It's built from scratch using dependency injection, D.R.Y. paradigm, event emitters and deferred/promises.

https://github.com/pocesar/node-stratum

  • Defer and promise based code instead of callbacks (avoid callback hell)
  • Simple but powerful API for managing both server and client
  • Build-in support for spawn coins daemons (bitcoind, litecoind, etc) process and accept RPC calls
  • Easy for you to add your own procedures do the RPC server (using expose)
  • No need to worry about .conf files for the daemons, everything is passed through command line the best way possible (but you may override arguments)
  • Optimized code reuse with class methods and dependency injection
  • All classes based on EventEmitter by default (through the Base class)
  • The client part make it easy, along with an RPC server, to setup your own farming pool for coins
  • You can create a proxy from it using the Client interface, mix up Stratum with your own RPC definition and commands
  • It's up to you to choose the logging module (like winston)

It's currently on active development, only missing the bitcoind control from the code, and then creation of the automated mocha tests, and should be ready to go. Preliminar tests showed it to be working well (with cpuminer and bfgminer, for example)


Title: Re: [WIP] My opensource Node.js Stratum server and client
Post by: Saturn7 on July 26, 2013, 09:04:24 PM
Thank you! Been waiting for this for a while. 1 BTC tip sent!


Title: Re: [WIP] My opensource Node.js Stratum server and client
Post by: pocesar on July 26, 2013, 09:22:16 PM
Thank you! Been waiting for this for a while. 1 BTC tip sent!

thanks man, really appreciate it. I should finish the coind part by this weekend I think (along with forking the process with the proper command line parameters).
after that, I will focus on testing every part of the server, using mocha and sinon (for mocks and stubs), and then try converting some python code for the stratum mine pool from slush to see how well it performs and add a benchmark to it as well. AFAIK, node is pretty good at handling connections, so I'm confident it will handle a large amount of data and connections per 'cluster'


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: jgarzik on July 28, 2013, 01:34:19 PM
Nice to see some further node.js work!  Good show.

Check these out,
https://github.com/gasteve/node-base58  ('base58-native' in npm)
https://github.com/gasteve/node-libcoin

We are cleaning up bitcoinjs-server into a nice library, and fixing many bugs found (including buffer overflows and memory leaks).

And watch
https://github.com/jgarzik/txtool
https://github.com/jgarzik/wally

for other node.js work.



Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on July 28, 2013, 01:50:24 PM
hey jgarzik, I'm already following you on github ;)

thanks for the links, they are pretty important, mainly for the base58 that I didn't find in npm earlier! I'm at the moment finishing a hash address detector, simple quick and dirty way to detect which addresses belong.

I've learned a lot from reading the bitcoinjs-server source, but couldn't make it work on Windows, unfortunately.


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: jgarzik on July 28, 2013, 03:38:25 PM
I've learned a lot from reading the bitcoinjs-server source, but couldn't make it work on Windows, unfortunately.

Hopefully node-libcoin will be a full replacement for bitcoinjs-server... :)



Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on July 28, 2013, 04:27:51 PM
I've learned a lot from reading the bitcoinjs-server source, but couldn't make it work on Windows, unfortunately.

Hopefully node-libcoin will be a full replacement for bitcoinjs-server... :)



nice! the more light weight, the merrier. should focusing in making it modular and independent, but that work well together.

I've created a pull request for the gyp binding to build base58 on windows.


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on July 29, 2013, 01:06:21 PM
done, finished my hacky detect cryption library (using base58-native) for node.js :)

https://github.com/pocesar/node-detect-cryptocoin


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on July 31, 2013, 02:34:05 AM
Improved the docs a bit. The main server part is completly functional. Only missing the automated tests!

https://github.com/pocesar/node-stratum


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: Saturn7 on July 31, 2013, 01:23:23 PM
Nice work, gonning to try it out over the weekend.


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on September 09, 2013, 06:58:22 AM
Worked a bit on the project on this weekend, after a long pause working on it because of work  :-[


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: erk on January 17, 2014, 10:49:11 AM
Anyone using it on a pool yet?


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on January 27, 2014, 05:53:22 AM
just updated it, when I have more spare time, I'll make 100% test coverage, only 2 parts to go.


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: flangefrog on January 27, 2014, 11:02:42 AM
Hi pocesar

Could you tell me what the difference is between your project and https://npmjs.org/package/stratum-pool ?


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on January 28, 2014, 01:15:57 AM
hey flangefrog, no idea, didn't even knew the existance of that repo. seems pretty new (first commit 21 days ago), so I'll check it out and report back

EDIT: It is a full fledged stratum pool, instead of stratum server and client module (my library have no pool funcionality whatsoever, its up to the developer to implement them). "stratum-pool" is more of a framework that is focused on building work to deliver to miners. although there are no tests or test coverage data for that library yet.

With my library, you can build pools, proxies, network endpoints for miners, etc, and implement in other types of libraries/frameworks, that aim to provide stratum support along with other functionalities, like a web interface, or other protocols, like X-Pushthrough. And I take stability and code congruence really seriously, along with tests and code coverage.


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: flangefrog on January 28, 2014, 05:31:32 AM
Thanks for your reply. I am going to start building a pool in a week or two. I am wanting to have multiple nodes in different locations to reduce latency to the miners. I assume I would run your code on each node, but would they be able to work together to solve the same block (so I would get a block more often with a lower hashrate)? I'm still learning how mining works.

I am going to be using CPPSRB for payments and build a custom frontend. Besides stuff like logging shares and making payments is there anything else cryptocoin related that I would need to build the pool? Basicly, can your project allow miners to connect, give me a way to log shares, and solve blocks. I'm a bit too busy right at the moment to try it out.


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on April 09, 2014, 11:38:48 PM
Soon I'm going to resume my work on the Proof of Concept using a really high performance solo mining endpoint using
https://github.com/pocesar/node-stratum as the building block. the project is in
https://github.com/pocesar/node-stratum-solo
you'll be able to create your own auto profit switching pool for example, or point all your ASICs to just one computer in the network, distributing correct unique work for your miners (and not dupe extra nonce, for example)


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: arruah on April 10, 2014, 01:01:23 PM
is it good to replace eloipool on my pool? :)


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: pocesar on April 12, 2014, 01:52:33 AM
you could, but you would have to implement the users, shares, etc by yourself. I'm focusing on quality, well tested, stable code instead of feature rich but unstable code. downtime, instability, security and exploitable bugs are my main concerns, see how many exchanges and pools were hacked lately.


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: soulreafer on April 17, 2014, 04:05:22 PM
possible that someone can explain how to build up a proxy with the client example. i tryed some with the net lib but i cant get it to work well


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: Polyatomic on May 06, 2014, 10:07:56 AM
Exellent project man.


Title: Re: [WIP] My opensource Node.js Stratum server and client + RPC interface
Post by: nahallacman on June 20, 2014, 02:07:59 AM
This software works great. I am in the process of trying to build a pool failover system that is miner agnostic and am using this code. I really appreciate that the basic stratum work is already done for me, thanks.