diff --git a/.gitmodules b/.gitmodules index 9437a31d3..052b103cd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "deps/jsonconfig"] path = deps/jsonconfig url = https://github.com/CoiniumServ/JsonConfig.git +[submodule "deps/csredis"] + path = deps/csredis + url = https://github.com/CoiniumServ/csredis.git diff --git a/.travis.yml b/.travis.yml index bb08ffeb0..d99e33692 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,16 @@ language: objective-c env: global: - - secure: "jan4aHikK+XOsBfJrhbFnrFlhAJ7p31z2KiXxoviFmO+5gIsZuhaEIniA5Kx/27rakj0CphoXxGL77WAYiEuVGJKl5j2j55zCYxSrs3ux7OuDut7A3NmwFXD65XcU75Pj12O3YMN96FKSY1ESdf0SBnti+hvgGDgIM47MOFWxME=" - EnableNuGetPackageRestore=true matrix: - MONO_VER="3.2.7" Package="pkg" - MONO_VER="3.4.0" Package="pkg" before_install: - wget "http://download.mono-project.com/archive/${MONO_VER}/macos-10-x86/MonoFramework-MDK-${MONO_VER}.macos10.xamarin.x86.${Package}" -- chmod +x ./build/extra/travis-build.sh -- ./build/extra/travis-build.sh +- ./build/extra/travis/install-mono.sh script: - xbuild build/CoiniumServ.sln -- chmod +x ./build/extra/run-tests.sh -- ./build/extra/run-tests.sh +- ./build/extra/travis/run-tests.sh notifications: - irc: chat.freenode.net#coinium-dev + irc: chat.freenode.net#coiniumserv-dev email: false -addons: - coverity_scan: - project: - name: CoiniumServ/CoiniumServ - description: C# Mono/.Net based crypto currency mining pool software - build_command_prepend: - build_command: xbuild build/CoiniumServ.sln - branch_pattern: coverity_scan diff --git a/README.md b/README.md index f9d1704cd..1294543ad 100644 --- a/README.md +++ b/README.md @@ -5,29 +5,115 @@ CoiniumServ was created to be used for [Coinium.org](http://www.coinium.org) mining pool network at first hand. You can check [some of pools](https://github.com/CoiniumServ/CoiniumServ/wiki/Pools) of the pools running CoiniumServ. * Official pools: [coinium.org](http://www.coinium.org) -* Official site: [coiniumserv.com](http://www.coiniumserv.com) ![CoiniumServ running over mono & ubuntu](http://i.imgur.com/izIB5nq.png) +### Support + +Start by reading our [FAQ](https://github.com/CoiniumServ/CoiniumServ/wiki/FAQ) and [wiki](https://github.com/CoiniumServ/CoiniumServ/wiki/). If you need further help, join us over our user-support channel [#coiniumserv@freenode](http://webchat.freenode.net/?channels=%23coiniumserv&prompt=1&uio=OT10cnVlde). + +You can also use our [issues](https://github.com/CoiniumServ/CoiniumServ/issues) page to report bugs. + +* Official site: [coiniumserv.com](http://www.coiniumserv.com) +* [Support forums](http://forum.coinium.org/forum/19-support/) +* IRC (**irc.freenode.net**): + - **#coiniumserv** [user support](http://webchat.freenode.net/?channels=%23coiniumserv&prompt=1&uio=OT10cnVlde) + - **#coiniumserv-dev** [dev talk](http://webchat.freenode.net/?channels=%23coiniumserv-dev&prompt=1&uio=OT10cnVlde) + - **#coinium** [official pools](http://webchat.freenode.net/?channels=%23coinium&prompt=1&uio=OT10cnVlde) +* [Twitter](http://twitter.com/coinium) +* [Bitcointalk.org](https://bitcointalk.org/index.php?topic=604476.0) +* [Bitcoin wiki](https://en.bitcoin.it/wiki/CoiniumServ) + +### Donation + +You can contribute the development of the project by donating; + +* BTC: `18qqrtR4xHujLKf9oqiCsjmwmH5vGpch4D` +* LTC: `LMXfRb3w8cMUBfqZb6RUkFTPaT6vbRozPa` +* DOGE: `DM8FW8REMHj3P4xtcMWDn33ccjikCWJnQr` +* RDD: `Rb9kcLs96VDHTmiXVjcWC2RBsfCJ73UQyr` + +If you would like to automatically donate a percentage of your pool's earning to support the project, check the [donation setup](https://github.com/CoiniumServ/CoiniumServ/wiki/Donation) guide. + +###### Donors + +Here is a list of our generous donors that keep the project ongoing; + +* [reddapi.com](https://www.reddapi.com) + +###### Bounties + +BountySource integration available over [here](https://www.bountysource.com/trackers/401667-coiniumserv). You can set bounties and solve them. + +[![Bountysource](https://api.bountysource.com/badge/team?team_id=760&style=bounties_received)](https://www.bountysource.com/teams/coinium/issues?utm_source=Coinium&utm_medium=shield&utm_campaign=TEAM_BADGE_1) + +###### Tips + +You can send tips and furher support the project or get tips for contributing by commiting. + +[![tip for next commit](http://tip4commit.com/projects/760.svg)](http://tip4commit.com/projects/760) + +### Status + +Expect a functioning alpha soon. + ### Features ###### Platform Agnostic -Can run on any platforms that C# can live in; -* *nix (including Linux) over mono -* Windows over DotNet. +Can run on these platforms; +* Linux/Unix over [mono](http://www.mono-project.com/). +* MacOS over [mono](http://www.mono-project.com/). +* Windows over [.Net](http://www.microsoft.com/net). ###### Multiplexed Structure * Multiple pools & ports. -* Multi-pool (switched) mining support. -* Multiple coin daemon connections. +* Multiple coin daemon connection support. * Multiple database layers. ###### Functionality -* Stratum server (over sockets) support. [in-development] -* Vanilla server (getwork & getblocktemplate over http server) support. [in-development] +* Stratum server (over TCP sockets). +* Stratum show_message support (MOTD & messages). +* Vanilla server (getwork over http server). [experimental] +* Daemon RPC interface. +* Block template / job managment. +* Generation transaction builder. +* Share processor. +* Payment processor. +* Proof of Work (PoW) and Proof of Stake (PoS) [in-development] support. +* Transaction messages support [in-development]. +* Vardiff support. +* Ban manager support that can handles miners flooding with invalid shares. +* Embedded web-server & front-end +* Full-stack API + +###### Hashing Algorithms + +_Working_ +* ✓ __Scrypt__ + +_Needs Testing_ + +* ✓ __SHA256__ +* ✓ __Blake__ +* ✓ __Fugue__ +* ✓ __Groestl__ +* ✓ __Keccak__ +* ✓ __SHAvite3__ +* ✓ __Skein__ +* ✓ __multi-algos: X11, X13, X14, X15, X17__ + +_Under Development_ + +* ✓ __Scrypt-Jane__ +* ✓ __Scrypt-N__ +* ✓ __Scrypt-OG__ +* ✓ __Quark__ +* ✓ __NIST5__ +* ✓ __Qubit__ +* ✓ __Hefty1__ ###### Development Model -* Strictly [follows](https://github.com/CoiniumServ/CoiniumServ/tree/develop/src/Tests) the [Test Driven Development](http://en.wikipedia.org/wiki/Test-driven_development) model. We have implemented extensive tests for all important functionality and never merge in code that breaks tests and stuff. Yet again, when a new functionality is introduced we also expect proper tests to be implemented within the PR. In simple words, most probably you won't notice any functionality-breaking changes within the repository. +* Strictly [follows](https://github.com/CoiniumServ/CoiniumServ/tree/develop/src/Tests) the [Test Driven Development](http://en.wikipedia.org/wiki/Test-driven_development) model. We have implemented extensive [tests](https://github.com/CoiniumServ/CoiniumServ/tree/develop/src/Tests) for all important functionality and never merge in code that breaks tests and stuff. Yet again, when a new functionality is introduced we also expect proper tests to be implemented within the PR. In simple words, most probably you won't notice any functionality-breaking changes within the repository. * A strict ruleset for the [Development Model](https://github.com/CoiniumServ/CoiniumServ/wiki/Development-Model). You can follow our bleeding-edge [Develop](https://github.com/CoiniumServ/CoiniumServ) branch or stay with-in the stable [Master](https://github.com/CoiniumServ/CoiniumServ/tree/master) branch. @@ -38,27 +124,14 @@ Make sure you check our [Getting Started](https://github.com/CoiniumServ/Coinium For Ubuntu, you can simply use our installer script; ``` -wget -O - https://raw.githubusercontent.com/CoiniumServ/CoiniumServ/develop/assets/installer/ubuntu.sh | bash +wget -O - https://raw.githubusercontent.com/CoiniumServ/CoiniumServ/develop/contrib/installers/ubuntu.sh | bash ``` ### Documentation -* [Documentation & Wiki](https://github.com/CoiniumServ/CoiniumServ/wiki/) +* [Wiki](https://github.com/CoiniumServ/CoiniumServ/wiki/) * [FAQ](https://github.com/CoiniumServ/CoiniumServ/wiki/FAQ) -* [Master Plan](https://github.com/CoiniumServ/CoiniumServ/wiki/Master-Plan) ( & motivation) - -### Support - -Start by reading our [FAQ](https://github.com/CoiniumServ/CoiniumServ/wiki/FAQ) and [wiki](https://github.com/CoiniumServ/CoiniumServ/wiki/). If you need further help, join us over our user-support channel [#coinium-serv@freenode](http://webchat.freenode.net/?channels=%23coinium-serv&prompt=1&uio=OT10cnVlde). - -You can also use our [issues](https://github.com/CoiniumServ/CoiniumServ/issues) page to report bugs. - -* IRC (**irc.freenode.net**): - - **#coinium-serv** [user support](http://webchat.freenode.net/?channels=%23coinium-serv&prompt=1&uio=OT10cnVlde) - - **#coinium-dev** [dev talk](http://webchat.freenode.net/?channels=%23coinium-dev&prompt=1&uio=OT10cnVlde) - - **#coinium** [official pools](http://webchat.freenode.net/?channels=%23coinium&prompt=1&uio=OT10cnVlde) -* [Twitter](http://twitter.com/coinium) -* [Bitcointalk.org](https://bitcointalk.org/index.php?topic=604476.0) +* [Master Plan](https://github.com/CoiniumServ/CoiniumServ/wiki/Master-Plan) ### Contributing @@ -67,29 +140,10 @@ Start reading by these; * [Developer's Guide](https://github.com/CoiniumServ/CoiniumServ/wiki/Developer's-Guide) * [Technical Documentation](https://github.com/CoiniumServ/CoiniumServ/wiki/Technical-Documentation) -### Donation - -You can contribute the development of the project by donating; - -* BTC: `18qqrtR4xHujLKf9oqiCsjmwmH5vGpch4D` -* LTC: `LMXfRb3w8cMUBfqZb6RUkFTPaT6vbRozPa` -* DOGE: `D7mzHQtkWD9B1Xwnmjfg9x2DofbaZBg6Lc` - -###### Bounties - -BountySource integration available over [here](https://www.bountysource.com/trackers/401667-coiniumserv). You can set bounties and solve them. - -[![Bountysource](https://api.bountysource.com/badge/team?team_id=760&style=bounties_received)](https://www.bountysource.com/teams/coinium/issues?utm_source=Coinium&utm_medium=shield&utm_campaign=TEAM_BADGE_1) - -###### Tips - -You can send tips and furher support the project or get tips for contributing by commiting. - -[![tip for next commit](http://tip4commit.com/projects/760.svg)](http://tip4commit.com/projects/760) - ### License -Copyright (C) 2013 - 2014, Coinium & CoiniumServ Project - http://www.coinium.org +Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org - +http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ This software is dual-licensed: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -104,5 +158,5 @@ GNU General Public License for more details. For the terms of this license, see [licenses/gpl_v3.txt](https://github.com/CoiniumServ/CoiniumServ/blob/develop/licenses/gpl_v3.txt). Alternatively, you can license this software under a commercial -license or white-label it as set out in [licenses/commercial.txt](https://github.com/CoiniumServ/CoiniumServ/blob/develop/licenses/commercial.txt). +license or white-label it as set out in [licenses/commercial.md](https://github.com/CoiniumServ/CoiniumServ/blob/develop/licenses/commercial.md). diff --git a/assets/config/coins/anoncoin.json b/assets/config/coins/anoncoin.json deleted file mode 100644 index fcc48d534..000000000 --- a/assets/config/coins/anoncoin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Anoncoin", - "symbol": "ANC", - "algorithm": "scrypt" -} \ No newline at end of file diff --git a/assets/config/coins/bitcoin.json b/assets/config/coins/bitcoin.json deleted file mode 100644 index f0413e78d..000000000 --- a/assets/config/coins/bitcoin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Bitcoin", - "symbol": "BTC", - "algorithm": "sha256" -} \ No newline at end of file diff --git a/assets/config/coins/catcoin.json b/assets/config/coins/catcoin.json deleted file mode 100644 index 6c951e38e..000000000 --- a/assets/config/coins/catcoin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Catcoin", - "symbol": "CAT", - "algorithm": "scrypt" -} \ No newline at end of file diff --git a/assets/config/coins/digibyte.json b/assets/config/coins/digibyte.json deleted file mode 100644 index ed65fed61..000000000 --- a/assets/config/coins/digibyte.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Digibyte", - "symbol": "DGB", - "algorithm": "scrypt" -} \ No newline at end of file diff --git a/assets/config/coins/earthcoin.json b/assets/config/coins/earthcoin.json deleted file mode 100644 index 272ebda3d..000000000 --- a/assets/config/coins/earthcoin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Earthcoin", - "symbol": "EAC", - "algorithm": "scrypt" -} \ No newline at end of file diff --git a/assets/config/coins/einsteinium.json b/assets/config/coins/einsteinium.json deleted file mode 100644 index d2575ef45..000000000 --- a/assets/config/coins/einsteinium.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Einsteinium", - "symbol": "EMC2", - "algorithm": "scrypt" -} diff --git a/assets/config/coins/feathercoin.json b/assets/config/coins/feathercoin.json deleted file mode 100644 index 26959d836..000000000 --- a/assets/config/coins/feathercoin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Feathercoin", - "symbol": "FTC", - "algorithm": "scrypt" -} diff --git a/assets/config/config-sample.json b/assets/config/config-sample.json deleted file mode 100644 index a441afd9d..000000000 --- a/assets/config/config-sample.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - # log configuration - "logs": { - "root": "logs", - "targets": [ - { - "enabled": true, - "type": "console", - "level": "debug" - }, - { - "enabled": true, - "type": "file", - "filename": "server.log", - "rolling": true, - "level": "information" - }, - { - "enabled": true, - "type": "file", - "filename": "debug.log", - "rolling": true, - "level": "verbose" - } - ] - }, - - # website configuration - "website": { - "enabled": false, - "bind": "0.0.0.0", - "port": 80 - }, - - # database configuration. - "database": { - "redis": { - "enabled": true, - "host": "127.0.0.1", - "port": 6379, - "password": "", - "databaseId": 0 - } - } -} \ No newline at end of file diff --git a/assets/config/pools/sample.json b/assets/config/pools/sample.json deleted file mode 100644 index 2b666a6da..000000000 --- a/assets/config/pools/sample.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "enabled": false, - - "coin": "litecoin.json", - - # coin daemon config - "daemon": { - "host": "127.0.0.1", - "port": 9333, - "username": "user", - "password": "password" - }, - - # stratum server config - "stratum": { - "enabled": true, - "bind": "0.0.0.0", - "port": 3333, - "diff": 16 - }, - - # vanilla server config - "vanilla": { - "enabled": true, - "bind": "localhost", - "port": 3334 - }, - - # payment processing - "payments": { - "enabled": false, - "interval": 60, - "minimum": 1 - }, - - # mpos compat mode - "mpos": { - "enabled": false, - "database": { - "host": "127.0.0.1", - "port": 3306, - "name": "db-name", - "user": "username", - "password": "password" - } - } -} \ No newline at end of file diff --git a/build/.gitignore b/build/.gitignore index 8f4c84746..b3ec5017c 100644 --- a/build/.gitignore +++ b/build/.gitignore @@ -1,2 +1,2 @@ /*.sln.DotSettings -*.userprefs +*.userprefs \ No newline at end of file diff --git a/build/CoiniumServ.sln b/build/CoiniumServ.sln index 9b5c4441e..11212bbd0 100644 --- a/build/CoiniumServ.sln +++ b/build/CoiniumServ.sln @@ -20,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonConfig", "..\deps\jsonc EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoiniumServGui", "..\src\CoiniumServGui\CoiniumServGui.csproj", "{1E2AF218-156A-40A0-8DA3-95DD13D93810}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSRedis", "..\deps\csredis\CSRedis\CSRedis.csproj", "{D35E185E-A7E1-41E1-846C-21944F56074F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -120,6 +122,21 @@ Global {1E2AF218-156A-40A0-8DA3-95DD13D93810}.Testing|Mixed Platforms.ActiveCfg = Release|Any CPU {1E2AF218-156A-40A0-8DA3-95DD13D93810}.Testing|Mixed Platforms.Build.0 = Release|Any CPU {1E2AF218-156A-40A0-8DA3-95DD13D93810}.Testing|x86.ActiveCfg = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Debug|x86.ActiveCfg = Debug|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Release|Any CPU.Build.0 = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Release|x86.ActiveCfg = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Testing|Any CPU.ActiveCfg = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Testing|Any CPU.Build.0 = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Testing|Mixed Platforms.ActiveCfg = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Testing|Mixed Platforms.Build.0 = Release|Any CPU + {D35E185E-A7E1-41E1-846C-21944F56074F}.Testing|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build/build-mono.sh b/build/extra/build-mono-debug.sh similarity index 94% rename from build/build-mono.sh rename to build/extra/build-mono-debug.sh index 70afd9b73..060d472c9 100755 --- a/build/build-mono.sh +++ b/build/extra/build-mono-debug.sh @@ -2,4 +2,5 @@ git submodule init git submodule update mozroots --import --ask-remove +cd .. xbuild CoiniumServ.sln diff --git a/build/extra/build-mono-release.sh b/build/extra/build-mono-release.sh new file mode 100755 index 000000000..2a86113fb --- /dev/null +++ b/build/extra/build-mono-release.sh @@ -0,0 +1,6 @@ +#!/bin/bash +cd .. +git submodule init +git submodule update +mozroots --import --ask-remove +xbuild /p:Configuration=Release CoiniumServ.sln diff --git a/build/extra/run-tests.sh b/build/extra/run-tests.sh index 75d67d539..d7296dfb4 100755 --- a/build/extra/run-tests.sh +++ b/build/extra/run-tests.sh @@ -1,2 +1,3 @@ #!/bin/bash +cd ../.. mono contrib/xunit/xunit.console.clr4.x86.exe src/Tests/bin/Debug/CoiniumServ.Tests.dll diff --git a/build/extra/travis-build.sh b/build/extra/travis/install-mono.sh old mode 100644 new mode 100755 similarity index 100% rename from build/extra/travis-build.sh rename to build/extra/travis/install-mono.sh diff --git a/build/extra/travis/run-tests.sh b/build/extra/travis/run-tests.sh new file mode 100755 index 000000000..75d67d539 --- /dev/null +++ b/build/extra/travis/run-tests.sh @@ -0,0 +1,2 @@ +#!/bin/bash +mono contrib/xunit/xunit.console.clr4.x86.exe src/Tests/bin/Debug/CoiniumServ.Tests.dll diff --git a/contrib/capture/fastcoin.pcapng b/contrib/capture/fastcoin.pcapng deleted file mode 100644 index 041cf9317..000000000 Binary files a/contrib/capture/fastcoin.pcapng and /dev/null differ diff --git a/contrib/capture/litecoin-testnet-mini.pcapng b/contrib/capture/litecoin-testnet-mini.pcapng deleted file mode 100644 index 8a9106a74..000000000 Binary files a/contrib/capture/litecoin-testnet-mini.pcapng and /dev/null differ diff --git a/contrib/capture/litecoin-testnet.pcapng b/contrib/capture/litecoin-testnet.pcapng deleted file mode 100644 index f698fb15f..000000000 Binary files a/contrib/capture/litecoin-testnet.pcapng and /dev/null differ diff --git a/contrib/coin-daemon/sample-config.conf b/contrib/coin/sample.conf similarity index 51% rename from contrib/coin-daemon/sample-config.conf rename to contrib/coin/sample.conf index 9ea23e680..0fb663bf2 100644 --- a/contrib/coin-daemon/sample-config.conf +++ b/contrib/coin/sample.conf @@ -7,4 +7,6 @@ rpcport=9333 #testnet=1 # testnet block explorers: -# litecoin: http://testnet.litecointools.com/ \ No newline at end of file +# bitcoin https://chain.so/testnet/btc +# litecoin: https://chain.so/testnet/ltc +# dogecoin: https://chain.so/testnet/doge diff --git a/assets/installer/ubuntu.sh b/contrib/installers/ubuntu.sh similarity index 74% rename from assets/installer/ubuntu.sh rename to contrib/installers/ubuntu.sh index 7e9e262dc..161f8cb25 100644 --- a/assets/installer/ubuntu.sh +++ b/contrib/installers/ubuntu.sh @@ -1,6 +1,6 @@ #!/bin/bash echo "Making sure git and mono is installed.." -sudo apt-get install git-core mono-complete +sudo apt-get -y --force-yes install git-core mono-complete echo "Cloning CoiniumServ.." git clone https://github.com/CoiniumServ/CoiniumServ.git cd CoiniumServ @@ -8,7 +8,7 @@ echo "Cloning submodules.." git submodule init git submodule update echo "Building CoiniumServ.." -cd build -./build-mono.sh +cd build/extra +./build-mono-release.sh cd .. echo "CoiniumServ build done.." diff --git a/contrib/performance/Readme.md b/contrib/performance/Readme.md new file mode 100644 index 000000000..c74dfa347 --- /dev/null +++ b/contrib/performance/Readme.md @@ -0,0 +1,4 @@ +This folder contains configuration for performance tests; + +* *.rider tests: [HttpRider](https://httprider.codeplex.com/) +* *.jmx tests: [Apacha JMeter](http://jmeter.apache.org/download_jmeter.cgi) \ No newline at end of file diff --git a/contrib/performance/web.jmx b/contrib/performance/web.jmx new file mode 100644 index 000000000..652de6b1a --- /dev/null +++ b/contrib/performance/web.jmx @@ -0,0 +1,153 @@ + + + + + + false + false + + + + + + + + continue + + false + 2 + + 1000 + 1 + 1373789594000 + 1373789594000 + false + + + + + + + + + 127.0.0.1 + 91 + + + + + + 4 + + + + + + + + + + + + + / + GET + true + false + true + false + false + + + + + + + + + + + + + + /changes.html + GET + true + false + true + false + false + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + false + false + false + false + false + 0 + true + + + + + + + + + + true + johndoe + = + true + username + + + true + secret + = + true + password + + + + www.example.com + + + + + + /loginform.html + POST + true + false + true + false + false + + + + + + + diff --git a/contrib/performance/web.rider b/contrib/performance/web.rider new file mode 100644 index 000000000..8dcdee06a Binary files /dev/null and b/contrib/performance/web.rider differ diff --git a/deps/csredis b/deps/csredis new file mode 160000 index 000000000..6667063d1 --- /dev/null +++ b/deps/csredis @@ -0,0 +1 @@ +Subproject commit 6667063d156bf04673449996b4f3560918631c4c diff --git a/deps/jsonconfig b/deps/jsonconfig index ec1a5567a..4bfac3474 160000 --- a/deps/jsonconfig +++ b/deps/jsonconfig @@ -1 +1 @@ -Subproject commit ec1a5567a669663cf0df07a897188ac9e1f57972 +Subproject commit 4bfac34740819e2dd6ef8655a59e43f37cd01b2c diff --git a/licenses/commercial.md b/licenses/commercial.md new file mode 100644 index 000000000..1b98f181b --- /dev/null +++ b/licenses/commercial.md @@ -0,0 +1,3 @@ +You have to acquire a commercial license in order to be able to use this project commercially (ie selling hosted solutions) or while-label it. + +Please contact us over [http://blog.coinium.org/contact/](http://blog.coinium.org/contact/) for more details. diff --git a/src/CoiniumServ/App.config b/src/CoiniumServ/App.config index 9bf7ed104..2a96593e9 100644 --- a/src/CoiniumServ/App.config +++ b/src/CoiniumServ/App.config @@ -1,18 +1,37 @@  - - - + + +
+ + + + + - + - + + + + + + + + + + + + + + + diff --git a/src/CoiniumServ/Banning/BanConfig.cs b/src/CoiniumServ/Banning/BanConfig.cs new file mode 100644 index 000000000..81df6caa1 --- /dev/null +++ b/src/CoiniumServ/Banning/BanConfig.cs @@ -0,0 +1,58 @@ +#region License +// +// CoiniumServ - Crypto Currency Mining Pool Server Software +// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ +// +// This software is dual-licensed: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// For the terms of this license, see licenses/gpl_v3.txt. +// +// Alternatively, you can license this software under a commercial +// license or white-label it as set out in licenses/commercial.txt. +// +#endregion + +using System; +using Serilog; + +namespace CoiniumServ.Banning +{ + public class BanConfig : IBanConfig + { + public bool Enabled { get; private set; } + public int Duration { get; private set; } + public int InvalidPercent { get; private set; } + public int CheckThreshold { get; private set; } + public int PurgeInterval { get; private set; } + public bool Valid { get; private set; } + + public BanConfig(dynamic config) + { + try + { + // load the config data. + Enabled = config.enabled; + Duration = config.duration == 0 ? 600 : config.duration; + InvalidPercent = config.invalidPercent == 0 ? 50 : config.invalidPercent; + CheckThreshold = config.checkThreshold == 0 ? 100 : config.checkThreshold; + PurgeInterval = config.purgeInterval == 0 ? 300 : config.purgeInterval; + + Valid = true; + } + catch (Exception e) + { + Valid = false; + Log.Logger.ForContext().Error(e, "Error loading banning configuration"); + } + } + } +} diff --git a/src/CoiniumServ/Banning/BanManager.cs b/src/CoiniumServ/Banning/BanManager.cs new file mode 100644 index 000000000..bd2b94134 --- /dev/null +++ b/src/CoiniumServ/Banning/BanManager.cs @@ -0,0 +1,166 @@ +#region License +// +// CoiniumServ - Crypto Currency Mining Pool Server Software +// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ +// +// This software is dual-licensed: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// For the terms of this license, see licenses/gpl_v3.txt. +// +// Alternatively, you can license this software under a commercial +// license or white-label it as set out in licenses/commercial.txt. +// +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading; +using CoiniumServ.Miners; +using CoiniumServ.Pools.Config; +using CoiniumServ.Server.Mining.Stratum.Sockets; +using CoiniumServ.Server.Mining.Vanilla; +using CoiniumServ.Shares; +using CoiniumServ.Utils.Helpers.Time; +using Serilog; + +namespace CoiniumServ.Banning +{ + public class BanManager:IBanManager + { + public IBanConfig Config { get; private set; } + + private readonly Dictionary _bannedIps; + + private readonly Timer _timer; + + private readonly ILogger _logger; + + public BanManager(IPoolConfig poolConfig, IShareManager shareManager) + { + Config = poolConfig.Banning; + + if (!Config.Enabled) + return; + + _logger = Log.ForContext().ForContext("Component", poolConfig.Coin.Name); + _bannedIps = new Dictionary(); + _timer = new Timer(CheckBans, null, Timeout.Infinite, Timeout.Infinite); // create the timer as disabled. + + shareManager.ShareSubmitted += OnShare; + + CheckBans(null); + } + + private void OnShare(object sender, EventArgs e) + { + var shareArgs = (ShareEventArgs)e; + var miner = shareArgs.Miner; + + if (miner == null) + return; + + var totalShares = miner.ValidShares + miner.InvalidShares; + + if (totalShares < Config.CheckThreshold) // check if we exceeded the threshold for checks. + return; + + var invalidPercentage = miner.InvalidShares/totalShares*100; + + if (invalidPercentage < Config.InvalidPercent) + // if the miner didn't reach the invalid share percentage, reset his stats. + { + miner.ValidShares = 0; + miner.InvalidShares = 0; + } + else // he needs a ban + { + _logger.Information("Banned miner {0:l} because of high percentage of invalid shares: {1}%.", miner.Username, invalidPercentage); + Ban(miner); + } + } + + private void Ban(IMiner miner) + { + // TODO: add vanilla miners to banlist too. + if (miner is IVanillaMiner) // as vanilla miners doesn't use persistent connections, we don't need to disconect him + return; // but just blacklist his ip. + + var client = (IClient) miner; + var ip = client.Connection.RemoteEndPoint.Address; + + if(!_bannedIps.ContainsKey(ip)) + _bannedIps.Add(ip, TimeHelpers.NowInUnixTime()); + + client.Connection.Disconnect(); + } + + public bool IsBanned(IPAddress ip) + { + if (!Config.Enabled) // if banning is not enabled, + return false; // just skip queries. + + if (!_bannedIps.ContainsKey(ip)) // check if ip exists in banlist. + return false; + + if (!BanExpired(ip)) // if ip has still an ongoing ban. + return true; + + RemoveBan(ip); // if the code flow reaches here, it means the ban has been expired, so remove it first. + return false; // and tell that ip has no bans. + } + + public void CheckBans(object state) + { + var expiredBans = 0; + var banlist = _bannedIps.ToDictionary(x => x.Key); // get a copy of the current banlist + + foreach (var pair in banlist) + { + if (!BanExpired(pair.Key)) // check if the ip should be still banned? + continue; + + expiredBans++; + RemoveBan(pair.Key); + } + + var remainingBans = _bannedIps.Count; + + if(expiredBans > 0) + _logger.Information("Cleared {0} expired bans [remaining bans: {1}].", expiredBans, remainingBans); + else + _logger.Information("No expired bans found to be cleared [remaining bans: {0}].", remainingBans); + + // reset the recache timer. + _timer.Change(Config.PurgeInterval * 1000, Timeout.Infinite); + } + + private bool BanExpired(IPAddress ip) + { + var banTime = _bannedIps[ip]; + + var elapsedTime = TimeHelpers.NowInUnixTime() - banTime; // elapsed time since his ban. + var timeLeft = Config.Duration - elapsedTime; // time left for his ban + + if (timeLeft > 0) // if he has still remaining time + return false; + + return true; + } + + private void RemoveBan(IPAddress ip) + { + _bannedIps.Remove(ip); + } + } +} diff --git a/src/CoiniumServ/Mining/Jobs/Tracker/JobTrackerFactory.cs b/src/CoiniumServ/Banning/IBanConfig.cs similarity index 58% rename from src/CoiniumServ/Mining/Jobs/Tracker/JobTrackerFactory.cs rename to src/CoiniumServ/Banning/IBanConfig.cs index 4ad1ea786..2f1807f6f 100644 --- a/src/CoiniumServ/Mining/Jobs/Tracker/JobTrackerFactory.cs +++ b/src/CoiniumServ/Banning/IBanConfig.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -21,29 +21,32 @@ // #endregion -using Coinium.Repository.Context; +using CoiniumServ.Configuration; -namespace Coinium.Mining.Jobs.Tracker +namespace CoiniumServ.Banning { - public class JobTrackerFactory:IJobTrackerFactory + public interface IBanConfig : IConfig { + bool Enabled { get; } + + /// + /// duration of ban when a miner gets flagged for so. + /// + int Duration { get; } + /// - /// The _kernel + /// percentage of invalid shares to trigger a ban. /// - private readonly IApplicationContext _applicationContext; + int InvalidPercent { get; } /// - /// Initializes a new instance of the class. + /// number of shares required before a miner's shares are considered for a ban. /// - /// The application context. - public JobTrackerFactory(IApplicationContext applicationContext) - { - _applicationContext = applicationContext; - } + int CheckThreshold { get; } - public IJobTracker Get() - { - return _applicationContext.Container.Resolve(); - } + /// + /// purge interval in seconds that bans are checked to see if they are expired. + /// + int PurgeInterval { get; } } } diff --git a/src/CoiniumServ/Banning/IBanManager.cs b/src/CoiniumServ/Banning/IBanManager.cs new file mode 100644 index 000000000..ce70f7736 --- /dev/null +++ b/src/CoiniumServ/Banning/IBanManager.cs @@ -0,0 +1,34 @@ +#region License +// +// CoiniumServ - Crypto Currency Mining Pool Server Software +// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ +// +// This software is dual-licensed: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// For the terms of this license, see licenses/gpl_v3.txt. +// +// Alternatively, you can license this software under a commercial +// license or white-label it as set out in licenses/commercial.txt. +// +#endregion + +using System.Net; + +namespace CoiniumServ.Banning +{ + public interface IBanManager + { + IBanConfig Config { get; } + + bool IsBanned(IPAddress ip); + } +} diff --git a/src/CoiniumServ/Blocks/BlockProcessor.cs b/src/CoiniumServ/Blocks/BlockProcessor.cs new file mode 100644 index 000000000..954ddd449 --- /dev/null +++ b/src/CoiniumServ/Blocks/BlockProcessor.cs @@ -0,0 +1,98 @@ +#region License +// +// CoiniumServ - Crypto Currency Mining Pool Server Software +// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ +// +// This software is dual-licensed: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// For the terms of this license, see licenses/gpl_v3.txt. +// +// Alternatively, you can license this software under a commercial +// license or white-label it as set out in licenses/commercial.txt. +// +#endregion + +using System; +using System.Linq; +using CoiniumServ.Daemon; +using CoiniumServ.Daemon.Exceptions; +using CoiniumServ.Daemon.Responses; +using CoiniumServ.Pools.Config; +using Serilog; + +namespace CoiniumServ.Blocks +{ + public class BlockProcessor:IBlockProcessor + { + private readonly IDaemonClient _daemonClient; + + private readonly IPoolConfig _poolConfig; + + private readonly ILogger _logger; + + public BlockProcessor(IPoolConfig poolConfig, IDaemonClient daemonClient) + { + _poolConfig = poolConfig; + _daemonClient = daemonClient; + _logger = Log.ForContext().ForContext("Component", poolConfig.Coin.Name); + } + + public bool GetBlockDetails(string blockHash, out Block block, out Transaction generationTransaction) + { + block = null; + generationTransaction = null; + + try + { + // query the block. + block = _daemonClient.GetBlock(blockHash); + + // read the very first (generation transaction) of the block + var generationTx = block.Tx.First(); + + // also make sure the transaction includes our pool wallet address. + generationTransaction = _daemonClient.GetTransaction(generationTx); + + return true; + } + catch (RpcException e) + { + _logger.Error("Queried block does not exist {0:l}, {1:l}", blockHash, e.Message); + return false; + } + } + + public bool CheckGenTxHash(Block block, string expectedTxHash) + { + // get the generation transaction for the block. + var genTx = block.Tx.First(); + + if (expectedTxHash == genTx) + return true; + + Log.Debug("Queried block {0:l} doesn't seem to belong us as reported generation transaction hash [{1:l}] doesn't match our expected one [{2:l}]", block.Hash, genTx, expectedTxHash); + return false; + } + + public bool ContainsPoolOutput(Transaction transaction) + { + // check if the transaction includes output for the configured central pool wallet address. + var gotPoolOutput = transaction.Details.Any(x => x.Address == _poolConfig.Wallet.Adress); + + if (gotPoolOutput) // if we got the correct pool output + return true; // then the block seems to belong us. + + Log.Debug("Queried block doesn't seem to belong us as generation transaction doesn't contain an output for pool's central wallet address: {0:}", _poolConfig.Wallet.Adress); + return false; + } + } +} diff --git a/src/CoiniumServ/Blocks/IBlockProcessor.cs b/src/CoiniumServ/Blocks/IBlockProcessor.cs new file mode 100644 index 000000000..011f51bd2 --- /dev/null +++ b/src/CoiniumServ/Blocks/IBlockProcessor.cs @@ -0,0 +1,36 @@ +#region License +// +// CoiniumServ - Crypto Currency Mining Pool Server Software +// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ +// +// This software is dual-licensed: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// For the terms of this license, see licenses/gpl_v3.txt. +// +// Alternatively, you can license this software under a commercial +// license or white-label it as set out in licenses/commercial.txt. +// +#endregion + +using CoiniumServ.Daemon.Responses; + +namespace CoiniumServ.Blocks +{ + public interface IBlockProcessor + { + bool GetBlockDetails(string blockHash, out Block block, out Transaction generationTransaction); + + bool CheckGenTxHash(Block block, string expectedTxHash); + + bool ContainsPoolOutput(Transaction transaction); + } +} diff --git a/src/CoiniumServ/Coin/Address/Base58.cs b/src/CoiniumServ/Coin/Address/Base58.cs index 30060c70c..b7abf5cbe 100644 --- a/src/CoiniumServ/Coin/Address/Base58.cs +++ b/src/CoiniumServ/Coin/Address/Base58.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,14 +20,15 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion + using System; using System.Linq; using System.Text; -using Coinium.Coin.Address.Exceptions; -using Coinium.Crypto; +using CoiniumServ.Coin.Address.Exceptions; +using CoiniumServ.Cryptology; using Org.BouncyCastle.Math; -namespace Coinium.Coin.Address +namespace CoiniumServ.Coin.Address { /// diff --git a/src/CoiniumServ/Coin/Address/Exceptions/AddressFormatException.cs b/src/CoiniumServ/Coin/Address/Exceptions/AddressFormatException.cs index 5a111684f..2ba7c1e5f 100644 --- a/src/CoiniumServ/Coin/Address/Exceptions/AddressFormatException.cs +++ b/src/CoiniumServ/Coin/Address/Exceptions/AddressFormatException.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ using System; -namespace Coinium.Coin.Address.Exceptions +namespace CoiniumServ.Coin.Address.Exceptions { /// /// Original implementation: https://github.com/CoiniumServ/BitcoinSharp/blob/55ca27107d200ede9896c1064de76b04d4daf9ef/src/Core/AddressFormatException.cs diff --git a/src/CoiniumServ/Coin/Address/Exceptions/InvalidWalletAddressException.cs b/src/CoiniumServ/Coin/Address/Exceptions/InvalidWalletAddressException.cs index 88ce71a99..9086fce28 100644 --- a/src/CoiniumServ/Coin/Address/Exceptions/InvalidWalletAddressException.cs +++ b/src/CoiniumServ/Coin/Address/Exceptions/InvalidWalletAddressException.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ using System; -namespace Coinium.Coin.Address.Exceptions +namespace CoiniumServ.Coin.Address.Exceptions { public class InvalidWalletAddressException : Exception { diff --git a/src/CoiniumServ/Coin/Coinbase/Serializers.cs b/src/CoiniumServ/Coin/Coinbase/Serializers.cs index fc39b17c8..72136583c 100644 --- a/src/CoiniumServ/Coin/Coinbase/Serializers.cs +++ b/src/CoiniumServ/Coin/Coinbase/Serializers.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,15 +20,16 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion + using System; using System.IO; using System.Text; -using Coinium.Server.Stratum.Notifications; -using Coinium.Utils.Extensions; -using Coinium.Utils.Helpers.Arrays; +using CoiniumServ.Jobs; +using CoiniumServ.Utils.Extensions; +using CoiniumServ.Utils.Helpers.Arrays; using Gibbed.IO; -namespace Coinium.Coin.Coinbase +namespace CoiniumServ.Coin.Coinbase { public static class Serializers { @@ -255,17 +256,17 @@ public static byte[] SerializeString(string input) if (input.Length < 0x10000) { stream.WriteValueU8(253); - stream.WriteValueU16(((UInt16)input.Length).LittleEndian()); // write packed lenght. + stream.WriteValueU16(((UInt16)input.Length).LittleEndian()); // write packed length. } - else if (input.Length < 0x100000000) + else if ((long)input.Length < 0x100000000) { stream.WriteValueU8(254); - stream.WriteValueU32(((UInt32)input.Length).LittleEndian()); // write packed lenght. + stream.WriteValueU32(((UInt32)input.Length).LittleEndian()); // write packed length. } else { stream.WriteValueU8(255); - stream.WriteValueU16(((UInt16)input.Length).LittleEndian()); // write packed lenght. + stream.WriteValueU16(((UInt16)input.Length).LittleEndian()); // write packed length. } stream.WriteString(input); diff --git a/src/CoiniumServ/Coin/Coinbase/Utils.cs b/src/CoiniumServ/Coin/Coinbase/Utils.cs index df102d62d..1511d4b8e 100644 --- a/src/CoiniumServ/Coin/Coinbase/Utils.cs +++ b/src/CoiniumServ/Coin/Coinbase/Utils.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,17 +20,18 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion + using System; using System.IO; using System.Linq; -using Coinium.Coin.Address; -using Coinium.Crypto; -using Coinium.Utils.Extensions; -using Coinium.Utils.Numerics; +using CoiniumServ.Coin.Address; +using CoiniumServ.Cryptology; +using CoiniumServ.Utils.Extensions; +using CoiniumServ.Utils.Numerics; using Gibbed.IO; using Serilog; -namespace Coinium.Coin.Coinbase +namespace CoiniumServ.Coin.Coinbase { /// /// Provides helper functions for "serialized CSscript formatting" as defined here: https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki#specification @@ -77,10 +78,13 @@ public static byte[] CoinAddressToScript(string address) /// Hashes the coinbase. /// /// + /// /// - public static Hash HashCoinbase(byte[] coinbase) + public static Hash HashCoinbase(byte[] coinbase, bool doubleDigest = true) { - return coinbase.DoubleDigest(); + return doubleDigest ? coinbase.DoubleDigest() : coinbase.Digest(); + + // TODO: fix this according - https://github.com/zone117x/node-stratum-pool/blob/eb4b62e9c4de8a8cde83c2b3756ca1a45f02b957/lib/jobManager.js#L69 } /// diff --git a/src/CoiniumServ/Coin/Config/CoinConfig.cs b/src/CoiniumServ/Coin/Config/CoinConfig.cs index fb4eb3e44..f95c1e0bc 100644 --- a/src/CoiniumServ/Coin/Config/CoinConfig.cs +++ b/src/CoiniumServ/Coin/Config/CoinConfig.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,7 +20,12 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion -namespace Coinium.Coin.Config + +using System; +using CoiniumServ.Daemon.Responses; +using Serilog; + +namespace CoiniumServ.Coin.Config { public class CoinConfig : ICoinConfig { @@ -28,20 +33,29 @@ public class CoinConfig : ICoinConfig public string Name { get; private set; } public string Symbol { get; private set; } public string Algorithm { get; private set; } + public string BlockExplorer { get; private set; } + public dynamic Options { get; private set; } public CoinConfig(dynamic config) { - if (config == null) + try + { + Name = config.name; + Symbol = config.symbol; + Algorithm = config.algorithm; + BlockExplorer = string.IsNullOrEmpty(config.blockExplorer) ? "https://altexplorer.net" : config.blockExplorer; + Options = config; + + if (Name == null || Symbol == null || Algorithm == null) // make sure we have valid name, symbol and algorithm data. + Valid = false; + else + Valid = true; + } + catch (Exception e) { Valid = false; - return; + Log.Logger.ForContext().Error("Error loading coin configuration: {0:l}", e.Message); } - - Name = config.name; - Symbol = config.symbol; - Algorithm = config.algorithm; - - Valid = true; } } } diff --git a/src/CoiniumServ/Coin/Config/ICoinConfig.cs b/src/CoiniumServ/Coin/Config/ICoinConfig.cs index d9574fc09..daeabb538 100644 --- a/src/CoiniumServ/Coin/Config/ICoinConfig.cs +++ b/src/CoiniumServ/Coin/Config/ICoinConfig.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -21,16 +21,35 @@ // #endregion -using Coinium.Utils.Configuration; +using CoiniumServ.Configuration; -namespace Coinium.Coin.Config +namespace CoiniumServ.Coin.Config { public interface ICoinConfig:IConfig { + /// + /// name of the coin + /// string Name { get; } + /// + /// 3 or 4 letter symbol for the coin + /// string Symbol { get; } + /// + /// The algorithm used by the coin. + /// string Algorithm { get; } + + /// + /// Block explorer for the coin. + /// + string BlockExplorer { get; } + + /// + /// Extra options provided that will be passed to coin algorithm. + /// + dynamic Options { get; } } } diff --git a/src/CoiniumServ/Coin/Helpers/Amount.cs b/src/CoiniumServ/Coin/Helpers/Amount.cs index 45f3002fc..e471ae832 100644 --- a/src/CoiniumServ/Coin/Helpers/Amount.cs +++ b/src/CoiniumServ/Coin/Helpers/Amount.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion -namespace Coinium.Coin.Helpers +namespace CoiniumServ.Coin.Helpers { /// /// Amount helper class. diff --git a/src/CoiniumServ/Coin/Helpers/Hashrate.cs b/src/CoiniumServ/Coin/Helpers/Hashrate.cs new file mode 100644 index 000000000..6113b588e --- /dev/null +++ b/src/CoiniumServ/Coin/Helpers/Hashrate.cs @@ -0,0 +1,46 @@ +#region License +// +// CoiniumServ - Crypto Currency Mining Pool Server Software +// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ +// +// This software is dual-licensed: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// For the terms of this license, see licenses/gpl_v3.txt. +// +// Alternatively, you can license this software under a commercial +// license or white-label it as set out in licenses/commercial.txt. +// +#endregion + +using System; + +namespace CoiniumServ.Coin.Helpers +{ + public static class Hashrate + { + public static string GetReadableHashrate(this UInt64 hashrate) + { + var index = -1; + double rate = hashrate; + + var units = new[] { "KH/s", "MH/s", "GH/s", "TH/s", "PH/s" }; + + do + { + rate = rate/1000; + index++; + } while (rate > 1000); + + return string.Format("{0:0.00} {1}", rate, units[index]); + } + } +} diff --git a/assets/Coinium.ico b/src/CoiniumServ/Coinium.ico similarity index 100% rename from assets/Coinium.ico rename to src/CoiniumServ/Coinium.ico diff --git a/src/CoiniumServ/CoiniumServ.csproj b/src/CoiniumServ/CoiniumServ.csproj index 6f85ee37d..c27f682c4 100644 --- a/src/CoiniumServ/CoiniumServ.csproj +++ b/src/CoiniumServ/CoiniumServ.csproj @@ -7,9 +7,9 @@ {5FCA1E48-0751-4625-9532-CB804DF55DB5} Exe Properties - Coinium + CoiniumServ CoiniumServ - v4.0 + v4.5 512 @@ -33,17 +33,17 @@ AnyCPU pdbonly true - bin\Release\ + ..\..\bin\Release\ TRACE prompt 4 false - Coinium.Program + CoiniumServ.Program - ..\..\assets\Coinium.ico + Coinium.ico @@ -54,96 +54,188 @@ False ..\..\build\packages\BouncyCastle.1.7.0\lib\Net40-Client\BouncyCastle.Crypto.dll - + + False ..\..\build\packages\CryptSharpOfficial.2.0.0.0\lib\CryptSharp.dll - + + False ..\..\build\packages\HashLib.2.0.1\lib\net40\HashLib.dll - - ..\..\build\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + False + ..\..\build\packages\Metrics.NET.0.1.10\lib\net45\Metrics.dll - - ..\..\build\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + False + ..\..\build\packages\Nancy.0.23.2\lib\net40\Nancy.dll - - ..\..\build\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + False + ..\..\build\packages\Nancy.CustomErrors.1.0.5.0\lib\net40\Nancy.CustomErrors.dll - + False - ..\..\build\packages\Nancy.0.23.0\lib\net40\Nancy.dll + ..\..\build\packages\Nancy.Hosting.Self.0.23.2\lib\net40\Nancy.Hosting.Self.dll - + False - ..\..\build\packages\Nancy.Hosting.Self.0.23.0\lib\net40\Nancy.Hosting.Self.dll + ..\..\build\packages\NancyFx.Metrics.0.1.10\lib\net45\Nancy.Metrics.dll + + + False + ..\..\build\packages\Nancy.Viewengines.Razor.0.23.2\lib\net40\Nancy.ViewEngines.Razor.dll False - ..\..\build\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll + ..\..\build\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll False - ..\..\build\packages\Serilog.1.3.30\lib\net40\Serilog.dll + ..\..\build\packages\Serilog.1.3.43\lib\net45\Serilog.dll False - ..\..\build\packages\Serilog.1.3.30\lib\net40\Serilog.FullNetFx.dll - - - ..\..\build\packages\StackExchange.Redis.1.0.312\lib\net40\StackExchange.Redis.dll + ..\..\build\packages\Serilog.1.3.43\lib\net45\Serilog.FullNetFx.dll - - ..\..\build\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll - - - ..\..\build\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll - - - ..\..\build\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll + + + False + ..\..\build\packages\Microsoft.AspNet.Razor.3.2.0\lib\net45\System.Web.Razor.dll - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - - - - - - + + + + + - - - - - - - - + + + + + + + + - - - @@ -153,31 +245,32 @@ - + - - - + - - + + + + + + + + + - - - - - + + + - - @@ -188,79 +281,66 @@ - + - - + - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + - - - - - - - - - + + + + + + + + + @@ -290,570 +370,552 @@ - - - - + + + + - + - - config\coins\21coin.json + + PreserveNewest - - config\coins\365coin.json + PreserveNewest - - config\coins\alphacoin.json + PreserveNewest - - config\coins\anoncoin.json + PreserveNewest - - config\coins\applecoin.json + PreserveNewest - - config\coins\arkenstone.json + PreserveNewest - - config\coins\arkhash.json + PreserveNewest - - config\coins\asiccoin.json + PreserveNewest - - config\coins\auroracoin.json + PreserveNewest - - config\coins\battlecoin.json + PreserveNewest - - config\coins\benjamins.json + PreserveNewest - - config\coins\betacoin.json + PreserveNewest - - config\coins\bitcoin.json + PreserveNewest - - config\coins\bitraam.json + PreserveNewest - - config\coins\bitstar.json + PreserveNewest - - config\coins\bluecoin.json + PreserveNewest - - config\coins\bottlecaps.json + PreserveNewest - - config\coins\bunnycoin.json + PreserveNewest - - config\coins\bytecoin.json + PreserveNewest - - config\coins\cachecoin.json + PreserveNewest - - config\coins\casinocoin.json + PreserveNewest - - config\coins\catcoin.json + PreserveNewest - - config\coins\coino.json + PreserveNewest - - config\coins\continuumcoin.json + PreserveNewest - - config\coins\copperbars.json + PreserveNewest - - config\coins\copperlark.json + PreserveNewest - - config\coins\cryptogenicbullion.json + PreserveNewest - - config\coins\cryptographicanomaly.json + PreserveNewest - - config\coins\cryptometh.json + PreserveNewest - - config\coins\darkcoin.json + PreserveNewest - - config\coins\defcoin.json + PreserveNewest - - config\coins\devcoin.json + PreserveNewest - - config\coins\diamondcoin.json + PreserveNewest - - config\coins\digibyte.json + PreserveNewest - - config\coins\dogecoin.json + PreserveNewest - - config\coins\earthcoin.json + PreserveNewest - - config\coins\einsteinium.json + PreserveNewest - - config\coins\elephantcoin.json + PreserveNewest - - config\coins\emark.json + PreserveNewest - - config\coins\emerald.json + PreserveNewest - - config\coins\execoin.json + PreserveNewest - - config\coins\ezcoin.json + PreserveNewest - - config\coins\fastcoin.json + PreserveNewest - - config\coins\fastcoinsha.json + PreserveNewest - - config\coins\feathercoin.json + PreserveNewest - - config\coins\fedoracoin.json + PreserveNewest - - config\coins\fireflycoin.json + PreserveNewest - - config\coins\flappycoin.json + PreserveNewest - - config\coins\florincoin.json + PreserveNewest - - config\coins\frankocoin.json + PreserveNewest - - config\coins\freecoin.json + PreserveNewest - - config\coins\freicoin.json + PreserveNewest - - config\coins\galaxycoin.json + PreserveNewest - - config\coins\galleon.json + PreserveNewest - - config\coins\gamecoin.json + PreserveNewest - - config\coins\giarcoin.json + PreserveNewest - - config\coins\globalboost.json + PreserveNewest - - config\coins\globalcoin.json + PreserveNewest - - config\coins\globaldenomination.json + PreserveNewest - - config\coins\goldpressedlatinum.json + PreserveNewest - - config\coins\grandcoin.json + PreserveNewest - - config\coins\groestlcoin.json + PreserveNewest - - config\coins\guarantcoin.json + PreserveNewest - - config\coins\helixcoin.json + PreserveNewest - - config\coins\hirocoin.json + PreserveNewest - - config\coins\hobonickels.json + PreserveNewest - - config\coins\internetcoin.json + PreserveNewest - - config\coins\ixcoin.json + PreserveNewest - - config\coins\jennycoin.json + PreserveNewest - - config\coins\joulecoin.json + PreserveNewest - - config\coins\junkcoin.json + PreserveNewest - - config\coins\kittehcoin.json + PreserveNewest - - config\coins\klondikecoin.json + PreserveNewest - - config\coins\krugercoin.json + PreserveNewest - - config\coins\kumacoin.json + PreserveNewest - - config\coins\litecoin.json + PreserveNewest - - config\coins\lottocoin.json + PreserveNewest - - config\coins\luckycoin.json + PreserveNewest - - config\coins\maxcoin.json + PreserveNewest - - config\coins\mazacoin.json + PreserveNewest - - config\coins\memecoin.json + PreserveNewest - - config\coins\microcoin.json + PreserveNewest - - config\coins\mintcoin.json + PreserveNewest - - config\coins\monacoin.json + PreserveNewest - - config\coins\muniti.json + PreserveNewest - - config\coins\myriadcoin.json + PreserveNewest - - config\coins\neocoin.json + PreserveNewest - - config\coins\netcoin.json + PreserveNewest - - config\coins\noirbits.json + PreserveNewest - - config\coins\octocoin.json + PreserveNewest - - config\coins\onecoin.json + PreserveNewest - - config\coins\opensourcecoin.json + PreserveNewest - - config\coins\pawncoin.json + PreserveNewest - - config\coins\peercoin.json + PreserveNewest - - config\coins\phoenixcoin.json + PreserveNewest - - config\coins\plncoin.json + PreserveNewest - - config\coins\potcoin.json + PreserveNewest - - config\coins\procoin.json + PreserveNewest - - config\coins\quarkcoin.json + PreserveNewest - - config\coins\radioactivecoin.json + PreserveNewest - - config\coins\README.md + PreserveNewest - - config\coins\reddcoin.json + PreserveNewest - - config\coins\ronpaulcoin.json + PreserveNewest - - config\coins\rubycoin.json + PreserveNewest - - config\coins\saffroncoin.json + PreserveNewest - - config\coins\sayacoin.json + PreserveNewest - - config\coins\sexcoin.json + PreserveNewest - - config\coins\sha1coin.json + PreserveNewest - - config\coins\skeincoin.json + PreserveNewest - - config\coins\spartancoin.json + PreserveNewest - - config\coins\spots.json + PreserveNewest - - config\coins\stablecoin.json + PreserveNewest - - config\coins\starcoin.json + PreserveNewest - - config\coins\stashcoin.json + PreserveNewest - - config\coins\stoopidcoin.json + PreserveNewest - - config\coins\suncoin.json + PreserveNewest - - config\coins\takcoin.json + PreserveNewest - - config\coins\teacoin.json + PreserveNewest - - config\coins\tekcoin.json + PreserveNewest - - config\coins\terracoin.json + PreserveNewest - - config\coins\tigercoin.json + PreserveNewest - - config\coins\ultimatecoin.json + PreserveNewest - - config\coins\ultracoin.json + PreserveNewest - - config\coins\unobtanium.json + PreserveNewest - - config\coins\velocitycoin.json + PreserveNewest - - config\coins\vertcoin.json + PreserveNewest - - config\coins\wearesatoshi.json + PreserveNewest - - config\coins\wecoin.json + PreserveNewest - - config\coins\whitecoin.json + PreserveNewest - - config\coins\xencoin.json + PreserveNewest - - config\coins\yacoin.json + PreserveNewest - - config\coins\ybcoin.json + PreserveNewest - - config\coins\zedcoin.json + PreserveNewest - - config\coins\zetacoin.json + PreserveNewest - - config\coins\zzcoin.json + PreserveNewest - - config-sample.json + PreserveNewest - - config\pools\sample.json + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + PreserveNewest - + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + {d35e185e-a7e1-41e1-846c-21944f56074f} + CSRedis + {047857ba-daa3-4ca7-afb8-a1b082b28c6a} Gibbed.IO @@ -864,16 +926,87 @@ - + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + - - - - - + + + + + + + + + + + +if $(ConfigurationName) == Debug ( +xcopy /s /y /R "$(SolutionDir)packages\Nancy.Viewengines.Razor.0.23.2\BuildProviders\Nancy.ViewEngines.Razor.BuildProviders.dll" "$(ProjectDir)bin\" +xcopy /s /y /R "$(SolutionDir)packages\Nancy.Viewengines.Razor.0.23.2\lib\net40\Nancy.ViewEngines.Razor.dll" "$(ProjectDir)bin\" +) + +
+
+
+

Overall Statistics

+
+
+
+ + + + + + + + + + + + + +
Workers Hashrate
@Model.Statistics.Global.WorkerCount@Model.Statistics.Global.Hashrate.GetReadableHashrate()
+
+
+
+
+ + +
+
+
+

Per Algorithm Statistics

+
+
+
+ + + + + + + + + + @foreach (var algorithm in Model.Statistics.Algorithms) + { + + + + + + } + +
Algorithm Workers Hashrate
@algorithm.Value.Name@algorithm.Value.WorkerCount@algorithm.Value.Hashrate.GetReadableHashrate()
+
+
+
+
+ + + +
+ + +
+
+
+

Per Pool Statistics

+
+
+
+ + + + + + + + + + + + + + @foreach (var pool in Model.Pools) + { + + + + + + + + + + } + +
Pool Hashrate Network Difficulty Workers Algorithm Current Block
@pool.Config.Coin.Name@pool.Statistics.Hashrate.GetReadableHashrate()@pool.Statistics.NetworkHashrate.GetReadableHashrate()@pool.Statistics.Difficulty@pool.Statistics.WorkerCount@pool.Config.Coin.Algorithm@pool.Statistics.CurrentBlock
+
+
+
+
+ +
\ No newline at end of file diff --git a/src/CoiniumServ/web/default/js/bootstrap.js b/src/CoiniumServ/web/default/js/bootstrap.js new file mode 100644 index 000000000..39ec4710e --- /dev/null +++ b/src/CoiniumServ/web/default/js/bootstrap.js @@ -0,0 +1,1951 @@ +/*! + * Bootstrap v3.1.0 (http://getbootstrap.com) + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + +if (typeof jQuery === 'undefined') { throw new Error('Bootstrap requires jQuery') } + +/* ======================================================================== + * Bootstrap: transition.js v3.1.0 + * http://getbootstrap.com/javascript/#transitions + * ======================================================================== + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ + + ++function ($) { + 'use strict'; + + // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) + // ============================================================ + + function transitionEnd() { + var el = document.createElement('bootstrap') + + var transEndEventNames = { + 'WebkitTransition' : 'webkitTransitionEnd', + 'MozTransition' : 'transitionend', + 'OTransition' : 'oTransitionEnd otransitionend', + 'transition' : 'transitionend' + } + + for (var name in transEndEventNames) { + if (el.style[name] !== undefined) { + return { end: transEndEventNames[name] } + } + } + + return false // explicit for ie8 ( ._.) + } + + // http://blog.alexmaccaw.com/css-transitions + $.fn.emulateTransitionEnd = function (duration) { + var called = false, $el = this + $(this).one($.support.transition.end, function () { called = true }) + var callback = function () { if (!called) $($el).trigger($.support.transition.end) } + setTimeout(callback, duration) + return this + } + + $(function () { + $.support.transition = transitionEnd() + }) + +}(jQuery); + +/* ======================================================================== + * Bootstrap: alert.js v3.1.0 + * http://getbootstrap.com/javascript/#alerts + * ======================================================================== + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ + + ++function ($) { + 'use strict'; + + // ALERT CLASS DEFINITION + // ====================== + + var dismiss = '[data-dismiss="alert"]' + var Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + var selector = $this.attr('data-target') + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 + } + + var $parent = $(selector) + + if (e) e.preventDefault() + + if (!$parent.length) { + $parent = $this.hasClass('alert') ? $this : $this.parent() + } + + $parent.trigger(e = $.Event('close.bs.alert')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent.trigger('closed.bs.alert').remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent + .one($.support.transition.end, removeElement) + .emulateTransitionEnd(150) : + removeElement() + } + + + // ALERT PLUGIN DEFINITION + // ======================= + + var old = $.fn.alert + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.alert') + + if (!data) $this.data('bs.alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + // ALERT NO CONFLICT + // ================= + + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } + + + // ALERT DATA-API + // ============== + + $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) + +}(jQuery); + +/* ======================================================================== + * Bootstrap: button.js v3.1.0 + * http://getbootstrap.com/javascript/#buttons + * ======================================================================== + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ + + ++function ($) { + 'use strict'; + + // BUTTON PUBLIC CLASS DEFINITION + // ============================== + + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + this.isLoading = false + } + + Button.DEFAULTS = { + loadingText: 'loading...' + } + + Button.prototype.setState = function (state) { + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() + + state = state + 'Text' + + if (!data.resetText) $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.options[state]) + + // push to event loop to allow forms to submit + setTimeout($.proxy(function () { + if (state == 'loadingText') { + this.isLoading = true + $el.addClass(d).attr(d, d) + } else if (this.isLoading) { + this.isLoading = false + $el.removeClass(d).removeAttr(d) + } + }, this), 0) + } + + Button.prototype.toggle = function () { + var changed = true + var $parent = this.$element.closest('[data-toggle="buttons"]') + + if ($parent.length) { + var $input = this.$element.find('input') + if ($input.prop('type') == 'radio') { + if ($input.prop('checked') && this.$element.hasClass('active')) changed = false + else $parent.find('.active').removeClass('active') + } + if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') + } + + if (changed) this.$element.toggleClass('active') + } + + + // BUTTON PLUGIN DEFINITION + // ======================== + + var old = $.fn.button + + $.fn.button = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.button') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.button', (data = new Button(this, options))) + + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.Constructor = Button + + + // BUTTON NO CONFLICT + // ================== + + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } + + + // BUTTON DATA-API + // =============== + + $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') + e.preventDefault() + }) + +}(jQuery); + +/* ======================================================================== + * Bootstrap: carousel.js v3.1.0 + * http://getbootstrap.com/javascript/#carousel + * ======================================================================== + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ + + ++function ($) { + 'use strict'; + + // CAROUSEL CLASS DEFINITION + // ========================= + + var Carousel = function (element, options) { + this.$element = $(element) + this.$indicators = this.$element.find('.carousel-indicators') + this.options = options + this.paused = + this.sliding = + this.interval = + this.$active = + this.$items = null + + this.options.pause == 'hover' && this.$element + .on('mouseenter', $.proxy(this.pause, this)) + .on('mouseleave', $.proxy(this.cycle, this)) + } + + Carousel.DEFAULTS = { + interval: 5000, + pause: 'hover', + wrap: true + } + + Carousel.prototype.cycle = function (e) { + e || (this.paused = false) + + this.interval && clearInterval(this.interval) + + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) + + return this + } + + Carousel.prototype.getActiveIndex = function () { + this.$active = this.$element.find('.item.active') + this.$items = this.$active.parent().children() + + return this.$items.index(this.$active) + } + + Carousel.prototype.to = function (pos) { + var that = this + var activeIndex = this.getActiveIndex() + + if (pos > (this.$items.length - 1) || pos < 0) return + + if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) + if (activeIndex == pos) return this.pause().cycle() + + return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + } + + Carousel.prototype.pause = function (e) { + e || (this.paused = true) + + if (this.$element.find('.next, .prev').length && $.support.transition) { + this.$element.trigger($.support.transition.end) + this.cycle(true) + } + + this.interval = clearInterval(this.interval) + + return this + } + + Carousel.prototype.next = function () { + if (this.sliding) return + return this.slide('next') + } + + Carousel.prototype.prev = function () { + if (this.sliding) return + return this.slide('prev') + } + + Carousel.prototype.slide = function (type, next) { + var $active = this.$element.find('.item.active') + var $next = next || $active[type]() + var isCycling = this.interval + var direction = type == 'next' ? 'left' : 'right' + var fallback = type == 'next' ? 'first' : 'last' + var that = this + + if (!$next.length) { + if (!this.options.wrap) return + $next = this.$element.find('.item')[fallback]() + } + + if ($next.hasClass('active')) return this.sliding = false + + var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + + this.sliding = true + + isCycling && this.pause() + + if (this.$indicators.length) { + this.$indicators.find('.active').removeClass('active') + this.$element.one('slid.bs.carousel', function () { + var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) + $nextIndicator && $nextIndicator.addClass('active') + }) + } + + if ($.support.transition && this.$element.hasClass('slide')) { + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + $active + .one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0) + }) + .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) + } else { + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid.bs.carousel') + } + + isCycling && this.cycle() + + return this + } + + + // CAROUSEL PLUGIN DEFINITION + // ========================== + + var old = $.fn.carousel + + $.fn.carousel = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.carousel') + var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) + var action = typeof option == 'string' ? option : options.slide + + if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.pause().cycle() + }) + } + + $.fn.carousel.Constructor = Carousel + + + // CAROUSEL NO CONFLICT + // ==================== + + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } + + + // CAROUSEL DATA-API + // ================= + + $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { + var $this = $(this), href + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex = $this.attr('data-slide-to') + if (slideIndex) options.interval = false + + $target.carousel(options) + + if (slideIndex = $this.attr('data-slide-to')) { + $target.data('bs.carousel').to(slideIndex) + } + + e.preventDefault() + }) + + $(window).on('load', function () { + $('[data-ride="carousel"]').each(function () { + var $carousel = $(this) + $carousel.carousel($carousel.data()) + }) + }) + +}(jQuery); + +/* ======================================================================== + * Bootstrap: collapse.js v3.1.0 + * http://getbootstrap.com/javascript/#collapse + * ======================================================================== + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ + + ++function ($) { + 'use strict'; + + // COLLAPSE PUBLIC CLASS DEFINITION + // ================================ + + var Collapse = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Collapse.DEFAULTS, options) + this.transitioning = null + + if (this.options.parent) this.$parent = $(this.options.parent) + if (this.options.toggle) this.toggle() + } + + Collapse.DEFAULTS = { + toggle: true + } + + Collapse.prototype.dimension = function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + Collapse.prototype.show = function () { + if (this.transitioning || this.$element.hasClass('in')) return + + var startEvent = $.Event('show.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var actives = this.$parent && this.$parent.find('> .panel > .in') + + if (actives && actives.length) { + var hasData = actives.data('bs.collapse') + if (hasData && hasData.transitioning) return + actives.collapse('hide') + hasData || actives.data('bs.collapse', null) + } + + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + .addClass('collapsing') + [dimension](0) + + this.transitioning = 1 + + var complete = function () { + this.$element + .removeClass('collapsing') + .addClass('collapse in') + [dimension]('auto') + this.transitioning = 0 + this.$element.trigger('shown.bs.collapse') + } + + if (!$.support.transition) return complete.call(this) + + var scrollSize = $.camelCase(['scroll', dimension].join('-')) + + this.$element + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + [dimension](this.$element[0][scrollSize]) + } + + Collapse.prototype.hide = function () { + if (this.transitioning || !this.$element.hasClass('in')) return + + var startEvent = $.Event('hide.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var dimension = this.dimension() + + this.$element + [dimension](this.$element[dimension]()) + [0].offsetHeight + + this.$element + .addClass('collapsing') + .removeClass('collapse') + .removeClass('in') + + this.transitioning = 1 + + var complete = function () { + this.transitioning = 0 + this.$element + .trigger('hidden.bs.collapse') + .removeClass('collapsing') + .addClass('collapse') + } + + if (!$.support.transition) return complete.call(this) + + this.$element + [dimension](0) + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + } + + Collapse.prototype.toggle = function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + + // COLLAPSE PLUGIN DEFINITION + // ========================== + + var old = $.fn.collapse + + $.fn.collapse = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.collapse') + var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) + + if (!data && options.toggle && option == 'show') option = !option + if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.Constructor = Collapse + + + // COLLAPSE NO CONFLICT + // ==================== + + $.fn.collapse.noConflict = function () { + $.fn.collapse = old + return this + } + + + // COLLAPSE DATA-API + // ================= + + $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + var target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + var $target = $(target) + var data = $target.data('bs.collapse') + var option = data ? 'toggle' : $this.data() + var parent = $this.attr('data-parent') + var $parent = parent && $(parent) + + if (!data || !data.transitioning) { + if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') + $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + } + + $target.collapse(option) + }) + +}(jQuery); + +/* ======================================================================== + * Bootstrap: dropdown.js v3.1.0 + * http://getbootstrap.com/javascript/#dropdowns + * ======================================================================== + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ + + ++function ($) { + 'use strict'; + + // DROPDOWN CLASS DEFINITION + // ========================= + + var backdrop = '.dropdown-backdrop' + var toggle = '[data-toggle=dropdown]' + var Dropdown = function (element) { + $(element).on('click.bs.dropdown', this.toggle) + } + + Dropdown.prototype.toggle = function (e) { + var $this = $(this) + + if ($this.is('.disabled, :disabled')) return + + var $parent = getParent($this) + var isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { + // if mobile we use a backdrop because click events don't delegate + $(' + + diff --git a/src/CoiniumServGui/CoiniumServGui.csproj b/src/CoiniumServGui/CoiniumServGui.csproj index 83ccbf406..7b97761ab 100644 --- a/src/CoiniumServGui/CoiniumServGui.csproj +++ b/src/CoiniumServGui/CoiniumServGui.csproj @@ -9,10 +9,11 @@ Properties CoiniumServGui CoiniumServGui - v4.0 + v4.5 512 ..\..\build\ true + AnyCPU @@ -23,6 +24,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -32,19 +34,20 @@ TRACE prompt 4 + false Coinium.ico - + + False ..\..\build\packages\ConsoleControl.1.0.3.1\lib\net40\ConsoleControl.dll - + + False ..\..\build\packages\ConsoleControl.1.0.3.1\lib\net40\ConsoleControlAPI.dll - - @@ -55,18 +58,6 @@ - - ..\..\build\packages\XDMessaging.4.0.9\lib\net40-Client\XDMessaging.dll - - - ..\..\build\packages\XDMessaging.4.0.9\lib\net40-Client\XDMessaging.Transport.Amazon.dll - - - ..\..\build\packages\XDMessaging.4.0.9\lib\net40-Client\XDMessaging.Transport.IOStream.dll - - - ..\..\build\packages\XDMessaging.4.0.9\lib\net40-Client\XDMessaging.Transport.WindowsMessaging.dll - @@ -88,6 +79,7 @@ True Resources.resx + True @@ -104,6 +96,12 @@ + + + {5fca1e48-0751-4625-9532-cb804df55db5} + CoiniumServ + + diff --git a/src/CoiniumServGui/MainForm.Designer.cs b/src/CoiniumServGui/MainForm.Designer.cs index a87aeab9b..2bdb6d1d9 100644 --- a/src/CoiniumServGui/MainForm.Designer.cs +++ b/src/CoiniumServGui/MainForm.Designer.cs @@ -30,31 +30,82 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.consoleControl1 = new ConsoleControl.ConsoleControl(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPageWeb = new System.Windows.Forms.TabPage(); + this.tabPageConsole = new System.Windows.Forms.TabPage(); + this.webBrowser = new System.Windows.Forms.WebBrowser(); + this.tabControl1.SuspendLayout(); + this.tabPageWeb.SuspendLayout(); + this.tabPageConsole.SuspendLayout(); this.SuspendLayout(); // // consoleControl1 // - this.consoleControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.consoleControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.consoleControl1.IsInputEnabled = true; - this.consoleControl1.Location = new System.Drawing.Point(0, 0); + this.consoleControl1.Location = new System.Drawing.Point(3, 3); this.consoleControl1.Name = "consoleControl1"; this.consoleControl1.SendKeyboardCommandsToProcess = false; this.consoleControl1.ShowDiagnostics = false; - this.consoleControl1.Size = new System.Drawing.Size(829, 512); + this.consoleControl1.Size = new System.Drawing.Size(815, 480); this.consoleControl1.TabIndex = 0; // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPageWeb); + this.tabControl1.Controls.Add(this.tabPageConsole); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(0, 0); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(829, 512); + this.tabControl1.TabIndex = 1; + // + // tabPageWeb + // + this.tabPageWeb.Controls.Add(this.webBrowser); + this.tabPageWeb.Location = new System.Drawing.Point(4, 22); + this.tabPageWeb.Name = "tabPageWeb"; + this.tabPageWeb.Padding = new System.Windows.Forms.Padding(3); + this.tabPageWeb.Size = new System.Drawing.Size(821, 486); + this.tabPageWeb.TabIndex = 0; + this.tabPageWeb.Text = "Site"; + this.tabPageWeb.UseVisualStyleBackColor = true; + // + // tabPageConsole + // + this.tabPageConsole.Controls.Add(this.consoleControl1); + this.tabPageConsole.Location = new System.Drawing.Point(4, 22); + this.tabPageConsole.Name = "tabPageConsole"; + this.tabPageConsole.Padding = new System.Windows.Forms.Padding(3); + this.tabPageConsole.Size = new System.Drawing.Size(821, 486); + this.tabPageConsole.TabIndex = 1; + this.tabPageConsole.Text = "Console"; + this.tabPageConsole.UseVisualStyleBackColor = true; + // + // webBrowser + // + this.webBrowser.Dock = System.Windows.Forms.DockStyle.Fill; + this.webBrowser.Location = new System.Drawing.Point(3, 3); + this.webBrowser.MinimumSize = new System.Drawing.Size(20, 20); + this.webBrowser.Name = "webBrowser"; + this.webBrowser.Size = new System.Drawing.Size(815, 480); + this.webBrowser.TabIndex = 0; + this.webBrowser.Url = new System.Uri("http://127.0.0.1", System.UriKind.Absolute); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(829, 512); - this.Controls.Add(this.consoleControl1); + this.Controls.Add(this.tabControl1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "MainForm"; this.Text = "CoiniumServ"; - this.Load += new System.EventHandler(this.Form1_Load); + this.Load += new System.EventHandler(this.MainForm_Load); + this.tabControl1.ResumeLayout(false); + this.tabPageWeb.ResumeLayout(false); + this.tabPageConsole.ResumeLayout(false); this.ResumeLayout(false); } @@ -62,6 +113,10 @@ private void InitializeComponent() #endregion private ConsoleControl.ConsoleControl consoleControl1; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPageWeb; + private System.Windows.Forms.TabPage tabPageConsole; + private System.Windows.Forms.WebBrowser webBrowser; } } diff --git a/src/CoiniumServGui/MainForm.cs b/src/CoiniumServGui/MainForm.cs index a713bfb8e..dd61127db 100644 --- a/src/CoiniumServGui/MainForm.cs +++ b/src/CoiniumServGui/MainForm.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ // #endregion using System; +using System.Reflection; using System.Windows.Forms; namespace CoiniumServGui @@ -30,7 +31,7 @@ public partial class MainForm : Form public MainForm() { InitializeComponent(); - Application.ApplicationExit += OnApplicationExit; + Application.ApplicationExit += OnApplicationExit; } private void OnApplicationExit(object sender, EventArgs e) @@ -38,8 +39,11 @@ private void OnApplicationExit(object sender, EventArgs e) consoleControl1.ProcessInterface.StopProcess(); } - private void Form1_Load(object sender, EventArgs e) + private void MainForm_Load(object sender, EventArgs e) { + Text = string.Format("CoiniumServ \"{0}\" - v{1}", CoiniumServ.Utils.Versions.VersionInfo.CodeName, + Assembly.GetAssembly(typeof(CoiniumServ.Utils.Versions.VersionInfo)).GetName().Version); + consoleControl1.StartProcess("CoiniumServ.exe",""); } } diff --git a/src/CoiniumServGui/Program.cs b/src/CoiniumServGui/Program.cs index 4ec537ef1..cee6eda49 100644 --- a/src/CoiniumServGui/Program.cs +++ b/src/CoiniumServGui/Program.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/CoiniumServGui/Properties/AssemblyInfo.cs b/src/CoiniumServGui/Properties/AssemblyInfo.cs index 371b44427..8a46d6307 100644 --- a/src/CoiniumServGui/Properties/AssemblyInfo.cs +++ b/src/CoiniumServGui/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/CoiniumServGui/Properties/Resources.Designer.cs b/src/CoiniumServGui/Properties/Resources.Designer.cs index 85e927b7e..e4fdd4ce8 100644 --- a/src/CoiniumServGui/Properties/Resources.Designer.cs +++ b/src/CoiniumServGui/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace CoiniumServGui.Properties -{ - - +namespace CoiniumServGui.Properties { + using System; + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -22,48 +22,40 @@ namespace CoiniumServGui.Properties [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CoiniumServGui.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/src/CoiniumServGui/Properties/Settings.Designer.cs b/src/CoiniumServGui/Properties/Settings.Designer.cs index 6d79175fe..620124e0c 100644 --- a/src/CoiniumServGui/Properties/Settings.Designer.cs +++ b/src/CoiniumServGui/Properties/Settings.Designer.cs @@ -8,21 +8,17 @@ // //------------------------------------------------------------------------------ -namespace CoiniumServGui.Properties -{ - - +namespace CoiniumServGui.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/src/CoiniumServGui/app.config b/src/CoiniumServGui/app.config index 2fb01017b..c7b49a455 100644 --- a/src/CoiniumServGui/app.config +++ b/src/CoiniumServGui/app.config @@ -1,7 +1,13 @@  - - - - - \ No newline at end of file + + + + + + + + + + + diff --git a/src/CoiniumServGui/packages.config b/src/CoiniumServGui/packages.config index 46642571a..ace79479e 100644 --- a/src/CoiniumServGui/packages.config +++ b/src/CoiniumServGui/packages.config @@ -1,5 +1,4 @@  - - + \ No newline at end of file diff --git a/src/Tests/App.config b/src/Tests/App.config index 16b7606d6..80a4170e2 100644 --- a/src/Tests/App.config +++ b/src/Tests/App.config @@ -3,16 +3,24 @@ - + - + - + + + + + + + + + diff --git a/src/Tests/Coin/AmountTests.cs b/src/Tests/Coin/AmountTests.cs index e194c8bfb..f78d39901 100644 --- a/src/Tests/Coin/AmountTests.cs +++ b/src/Tests/Coin/AmountTests.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,11 +20,12 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion -using Coinium.Coin.Helpers; + +using CoiniumServ.Coin.Helpers; using Should.Fluent; using Xunit; -namespace Tests.Coin +namespace CoiniumServ.Tests.Coin { public class AmountTests { diff --git a/src/Tests/Coin/Base58Test.cs b/src/Tests/Coin/Base58Test.cs index 41a09d0be..ed44f27ee 100644 --- a/src/Tests/Coin/Base58Test.cs +++ b/src/Tests/Coin/Base58Test.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,15 +20,16 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion + using System; using System.Text; -using Coinium.Coin.Address; -using Coinium.Coin.Address.Exceptions; +using CoiniumServ.Coin.Address; +using CoiniumServ.Coin.Address.Exceptions; using Org.BouncyCastle.Math; using Should.Fluent; using Xunit; -namespace Tests.Coin +namespace CoiniumServ.Tests.Coin { public class Base58Test { diff --git a/src/Tests/Coin/Coinbase/SerializersTests.cs b/src/Tests/Coin/Coinbase/SerializersTests.cs index 74542722d..8262e8b14 100644 --- a/src/Tests/Coin/Coinbase/SerializersTests.cs +++ b/src/Tests/Coin/Coinbase/SerializersTests.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,17 +20,19 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion + using System; +using System.Collections.Generic; using System.Linq; -using Coinium.Coin.Coinbase; -using Coinium.Crypto.Algorithms; -using Coinium.Daemon; -using Coinium.Daemon.Responses; -using Coinium.Mining.Jobs; -using Coinium.Server.Stratum.Notifications; -using Coinium.Transactions; -using Coinium.Transactions.Script; -using Coinium.Utils.Extensions; +using CoiniumServ.Coin.Coinbase; +using CoiniumServ.Cryptology.Algorithms; +using CoiniumServ.Daemon; +using CoiniumServ.Daemon.Responses; +using CoiniumServ.Jobs; +using CoiniumServ.Payments; +using CoiniumServ.Transactions; +using CoiniumServ.Transactions.Script; +using CoiniumServ.Utils.Extensions; using Newtonsoft.Json; using NSubstitute; using Should.Fluent; @@ -93,7 +95,7 @@ 2014-06-25 13:24:04 [Pool] [litecoin] (Thread 1) Block found: e242093d92f4c98bfd5dd1f9f6489652d1165f5ce4eed1f28747d2b8e3efd8b6 */ -namespace Tests.Coin.Coinbase +namespace CoiniumServ.Tests.Coin.Coinbase { public class SerializerTests { @@ -134,18 +136,25 @@ public SerializerTests() _outputs = Substitute.For(_daemonClient); double blockReward = 5000000000; // the amount rewarded by the block. - // sample recipient - const string recipient = "mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji"; + // sample reward recipient + var rewardsConfig = Substitute.For(); var amount = blockReward * 0.01; blockReward -= amount; - _outputs.AddRecipient(recipient, amount); + var rewards = new Dictionary { { "mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji", (float)amount } }; - // sample pool wallet - const string poolWallet = "mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq"; - _outputs.AddPool(poolWallet, blockReward); + rewardsConfig.GetEnumerator().Returns(rewards.GetEnumerator()); + foreach (var pair in rewards) + { + _outputs.AddRecipient(pair.Key, pair.Value); + } + // sample pool wallet + var walletConfig = Substitute.For(); + walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq"); + _outputs.AddPoolWallet(walletConfig.Adress, blockReward); + // generation transaction. - _generationTransaction = Substitute.For(_extraNonce, _daemonClient, _blockTemplate, false); + _generationTransaction = Substitute.For(_extraNonce, _daemonClient, _blockTemplate, walletConfig, rewardsConfig, false); _generationTransaction.Inputs.First().SignatureScript = _signatureScript; _generationTransaction.Outputs = _outputs; _generationTransaction.Create(); @@ -181,7 +190,7 @@ public void SerializeHeaderTest() // create the coinbase. var coinbase = Serializers.SerializeCoinbase(_job, extraNonce1, extraNonce2); - var coinbaseHash = Coinium.Coin.Coinbase.Utils.HashCoinbase(coinbase); + var coinbaseHash = CoiniumServ.Coin.Coinbase.Utils.HashCoinbase(coinbase); // create the merkle root. var merkleRoot = _job.MerkleTree.WithFirst(coinbaseHash).ReverseBuffer(); @@ -203,7 +212,7 @@ public void SerializeBlockTest() // create the coinbase. var coinbase = Serializers.SerializeCoinbase(_job, extraNonce1, extraNonce2); - var coinbaseHash = Coinium.Coin.Coinbase.Utils.HashCoinbase(coinbase); + var coinbaseHash = CoiniumServ.Coin.Coinbase.Utils.HashCoinbase(coinbase); // create the merkle root. var merkleRoot = _job.MerkleTree.WithFirst(coinbaseHash).ReverseBuffer(); diff --git a/src/Tests/Coin/Coinbase/UtilsTests.cs b/src/Tests/Coin/Coinbase/UtilsTests.cs index a6a7e1a09..102c9deb4 100644 --- a/src/Tests/Coin/Coinbase/UtilsTests.cs +++ b/src/Tests/Coin/Coinbase/UtilsTests.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,11 +20,8 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion -using Coinium.Coin.Coinbase; -using Should.Fluent; -using Xunit; -namespace Tests.Coin.Coinbase +namespace CoiniumServ.Tests.Coin.Coinbase { public class UtilsTests { diff --git a/src/Tests/Crypto/Merkle/MerkleRootTests.cs b/src/Tests/Crypto/Merkle/MerkleRootTests.cs deleted file mode 100644 index 940c764de..000000000 --- a/src/Tests/Crypto/Merkle/MerkleRootTests.cs +++ /dev/null @@ -1,189 +0,0 @@ -#region License -// -// CoiniumServ - Crypto Currency Mining Pool Server Software -// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ -// -// This software is dual-licensed: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// For the terms of this license, see licenses/gpl_v3.txt. -// -// Alternatively, you can license this software under a commercial -// license or white-label it as set out in licenses/commercial.txt. -// -#endregion - -using System.Collections.Generic; -using Coinium.Crypto.Merkle; -using Coinium.Utils.Extensions; -using Should.Fluent; -using Xunit; - -namespace Tests.Crypto.Merkle -{ - public class MerkleRootTests - { - /// - /// Tests bitcoin block 300384 with only a single (generation) transaction. - /// Block: http://blockexplorer.com/block/0000000000000000646aeda800ee605632799ead6257976b3805c66682b4d34e - /// - [Fact] - public void TestBlockWithSingleTransaction() - { - var hashlist = new List - { - "d43d6fbe5e46ee82847421c1609fe1203c0f3db0992ac98a06684b10676b8428".HexToByteArray() - }; - - var merkleTree = new MerkleRoot(hashlist); - var expected = "d43d6fbe5e46ee82847421c1609fe1203c0f3db0992ac98a06684b10676b8428".HexToByteArray(); - - merkleTree.Root.Bytes.Should().Equal(expected); - } - - /// - /// Tests a block with 3 fake transactions. - /// - [Fact] - public void TestBlockWithThreeTransactions() - { - var hashlist = new List - { - "b9e8f1d2cea2b609faae19049546c8d3826d4d5268e3b1843d24234e6cc65c91".HexToByteArray(), - "26d0d04050d9d036f6677c49b558a492a6bcfb75e1de6b5c9335d26e729e5cd4".HexToByteArray(), - "c13a822f47072f9b2236cea9c22ab7e5d92c0ac4fd2a63af2c4ed1f2e306efd5".HexToByteArray(), - }; - - var merkleTree = new MerkleRoot(hashlist); - var expected = "a907cc5d1de726136e50b1899672db2728c47897902718fbcfd133ed11331a66".HexToByteArray(); - - merkleTree.Root.Bytes.Should().Equal(expected); - } - - /// - /// Test bitcoin block 286819 merkle root against our merkle functions. - /// Why this block? Because it's quite popular for so. - /// Block: http://blockexplorer.com/block/0000000000000000e067a478024addfecdc93628978aa52d91fabd4292982a50 - /// Python implementation for the block: http://runnable.com/U3HnDaMrJFk3gkGW/bitcoin-block-merkle-root-286819-for-python - /// - [Fact] - public void TestBlockWithManyTransactions() - { - var hashlist = new List - { - "00baf6626abc2df808da36a518c69f09b0d2ed0a79421ccfde4f559d2e42128b".HexToByteArray(), - "91c5e9f288437262f218c60f986e8bc10fb35ab3b9f6de477ff0eb554da89dea".HexToByteArray(), - "46685c94b82b84fa05b6a0f36de6ff46475520113d5cb8c6fb060e043a0dbc5c".HexToByteArray(), - "ba7ed2544c78ad793ef5bb0ebe0b1c62e8eb9404691165ffcb08662d1733d7a8".HexToByteArray(), - "b8dc1b7b7ed847c3595e7b02dbd7372aa221756b718c5f2943c75654faf48589".HexToByteArray(), - "25074ef168a061fcc8663b4554a31b617683abc33b72d2e2834f9329c93f8214".HexToByteArray(), - "0fb8e311bffffadc6dc4928d7da9e142951d3ba726c8bde2cf1489b62fb9ebc5".HexToByteArray(), - "c67c79204e681c8bb453195db8ca7d61d4692f0098514ca198ccfd1b59dbcee3".HexToByteArray(), - "bd27570a6cbd8ad026bfdb8909fdae9321788f0643dea195f39cd84a60a1901b".HexToByteArray(), - "41a06e53ffc5108358ddcec05b029763d714ae9f33c5403735e8dee78027fe74".HexToByteArray(), - "cc2696b44cb07612c316f24c07092956f7d8b6e0d48f758572e0d611d1da6fb9".HexToByteArray(), - "8fc508772c60ace7bfeb3f5f3a507659285ea6f351ac0474a0a9710c7673d4fd".HexToByteArray(), - "62fed508c095446d971580099f976428fc069f32e966a40a991953b798b28684".HexToByteArray(), - "928eadbc39196b95147416eedf6f635dcff818916da65419904df8fde977d5db".HexToByteArray(), - "b137e685df7c1dffe031fb966a0923bb5d0e56f381e730bc01c6d5244cfe47c1".HexToByteArray(), - "b92207cee1f9e0bfbd797b05a738fab9de9c799b74f54f6b922f20bd5ec23dd6".HexToByteArray(), - "29d6f37ada0481375b6903c6480a81f8deaf2dcdba03411ed9e8d3e5684d02dd".HexToByteArray(), - "48158deb116e4fd0429fbbbae61e8e68cb6d0e0c4465ff9a6a990037f88c489c".HexToByteArray(), - "be64ea86960864cc0a0236bbb11f232faf5b19ae6e2c85518628f5fae37ec1ca".HexToByteArray(), - "081363552e9fff7461f1fc6663e1abd0fb2dd1c54931e177479a18c4c26260e8".HexToByteArray(), - "eb87c25dd2b2537b1ff3dbabc420e422e2a801f1bededa6fa49ef7980feaef70".HexToByteArray(), - "339e16fcc11deb61ccb548239270af43f5ad34c321416bada4b8d66467b1c697".HexToByteArray(), - "4ad6417a3a04179482ed2e4b7251c396e38841c6fba8d2ce9543337ab7c93c02".HexToByteArray(), - "c28a45cded020bf424b400ffc9cb6f2f85601934f18c34a4f78283247192056a".HexToByteArray(), - "882037cc9e3ee6ddc2d3eba86b7ca163533b5d3cbb16eaa38696bb0a2ea1137e".HexToByteArray(), - "179bb936305b46bb0a9df330f8701984c725a60e063ad5892fa97461570b5c04".HexToByteArray(), - "9517c585d1578cb327b7988f38e1a15c663955ea288a2292b40d27f232fbb980".HexToByteArray(), - "2c7e07d0cf42e5520bcbfe2f5ef63761a9ab9d7ccb00ea346195eae030f3b86f".HexToByteArray(), - "534f631fc42ae2d309670e01c7a0890e4bfb65bae798522ca14df09c81b09734".HexToByteArray(), - "104643385619adb848593eb668a8066d1f32650edf35e74b0fc3306cb6719448".HexToByteArray(), - "87ac990808239c768182a752f4f71cd98558397072883c7e137efb49d22b9231".HexToByteArray(), - "9b3e2f1c47d59a444e9b6dc725f0ac6baf160d22f3a9d399434e5e65b14eccb0".HexToByteArray(), - "fbe123066ae5add633a542f151663db4eb5a7053e388faadb40240671ae1b09b".HexToByteArray(), - "1dd07e92e20b3cb9208af040031f7cfc4efd46cc31ec27be20a1047965a42849".HexToByteArray(), - "2709bb9ed27353c1fd76b9240cab7576a44de68945e256ad44b2cb8d849a8060".HexToByteArray(), - "d0174db2c712573432a7869c1508f371f3a1058aeedddc1b53a7e04d7c56c725".HexToByteArray(), - "b4a16f724cddb8f77ddf3d2146a12c4be13d503885eaba3518a03da005009f62".HexToByteArray(), - "2aa706d75decbe57745e01d46f9f5d30a08dedaf3288cee14cc4948e3684e1d4".HexToByteArray(), - "ee49c5f6a5129ccaf2abebbc1d6d07a402a600af6221476b89aafaa683ca95b7".HexToByteArray(), - "bea1011c77874845e9b4c876ed2ceebd530d428dd4a564ad003d9211d40bb091".HexToByteArray(), - "f1e88ffc2b1de2aa4827002f06943ce5468735f7433f960bf01e75885b9f832b".HexToByteArray(), - "19247d017e002fb9143d1a89eb921222a94f8a3d0faaf2e05b0f594989edc4c4".HexToByteArray(), - "13f714ff62ee7d26b6d69ca980c141ebc54e9f71d2697083fe6c5efc1b02bd0f".HexToByteArray(), - "0c78cbb8246572f015fbdc53dc9798fa54d1119ec77c1f07ac310bcbcc40dbf8".HexToByteArray(), - "4bcde0ef92a6d24a2be7be50ac5e5299d776df2e6229ba5d475c2491da94f255".HexToByteArray(), - "0cfd7d1058502730cf0b2ffa880c78ef534651e06832b5d87c0d7eb84eac5b0c".HexToByteArray(), - "3a168f794d6e0c614429ad874317cc4cd67a8177214880ff6ea1704d29228c2f".HexToByteArray(), - "f9a555d817334397b402518d6fd959dc73d981ee7f5fe67969b63974ebbef127".HexToByteArray(), - "24b52691f66eaed4ce391a473902e309018257c98b9f02aaa33b399c9e6f3168".HexToByteArray(), - "a37b5e623dc26a180d9e2c9510d06885b014e86e533adb63ec40511e10b55046".HexToByteArray(), - "9dbaeb485e51d9e25a5621dc46e0bc0aaf51fb26be5acc4e370b96f62c469b80".HexToByteArray(), - "a6431d3d39f6c38c5df48405090752cab03bfdf5c77cf881b18a946807fba74a".HexToByteArray(), - "faa77e309f125373acf19855dd496fffe2f74962e545420844557a3adc7ebc11".HexToByteArray(), - "3523f52543ecfea2f78486dc91550fad0e6467d46d9d9c82ca63b2e0230bfa71".HexToByteArray(), - "a0583e358e42d77d18d1fd0533ff0a65615fc3b3112061ef92f168a00bf640c1".HexToByteArray(), - "42ae900888d5e5dde59c8e3d06e13db9e84ef05d27726d4b67fd00c50cd9406a".HexToByteArray(), - "154940777d3ff78f592ef02790131a59263c36b4958bbc836f9a767ea1a9f178".HexToByteArray(), - "6a0337de6ac75eecf748306e8ebc5bfe5c811a1481ae50f6956a9e7f26a679f5".HexToByteArray(), - "c99530c2148e09688d0b88795625943371183bf1f5d56c7446c6ed51ea133589".HexToByteArray(), - "626421dbe8ad6a0fd0d622d5dd3308a1cdc00b98575a41a91fe01a439e6f40bd".HexToByteArray(), - "b2f3a559f605a158cc395126c3cf394a7e92a53b7514c75157e1dc43a6c7f93e".HexToByteArray(), - "dffe06d1bea81f2a01c76786404bb867258f9e68013bf25454097ce935090738".HexToByteArray(), - "0860159ec7a2a51ce107c182a988c40b4bc2057a734354a1219b6c65e72640ed".HexToByteArray(), - "a405ff1bb51846b1867acc0b0da17f6f9616e592a0a7ff5ef3297c1ecfd60911".HexToByteArray(), - "a7d451924263284765f6343bca8a21b79b89ebfe611c7355dd88e0ec1c29e232".HexToByteArray(), - "41c758d08a4d3fe4d90645711589b832a2cd54dd25bd5b66e463e5d389a53aff".HexToByteArray(), - "a05c1a93a521fa5dbc1790cfbb808893453a428a65f2c6b2d51249fbb12db309".HexToByteArray(), - "90997920aa9786e10f513cfdd14e294feee6739cee1ab61b3fb1e3f42e7a915d".HexToByteArray(), - "99fcb9cb62c20a3135484a70bd3f73983f8f3b7b26266dad34f3993958a7642c".HexToByteArray(), - "e05f9a668b37e5f78bd3b9d047f29f92b33a87f11dd48390410006f858188b7b".HexToByteArray(), - "56dbc65895f7992da4a6985e7edba4d1c00879f1b28442c644c8a07658ceab27".HexToByteArray(), - "5e9004fe262b829563d0804656ba68b1de1690401f08a1915273230d8c902fc0".HexToByteArray(), - "1ea9ed3717523c5e304b7a7ac8058a87fb4f3fed8c6004769f226c9bb67e79c5".HexToByteArray(), - "f0f1a4c009b3f1b2729e89898e2f5c0fcdc312edea5df884a9c897cb90e4c566".HexToByteArray(), - "b5bb4ddf04863e6a60f33cb96c20dac8175d3bae55f335781503143c97a50e43".HexToByteArray(), - "f14cc97a20c6f627b4b78301352ae35463bc359362589cd178a06c0fa90850b7".HexToByteArray(), - "628801c8f614015c0fa0ccb2768cccc3e7b9d41ceed06071ce2534d31f7236d6".HexToByteArray(), - "3be1013c8f8da150e2195408093153b55b08b037fd92db8bb5e803f4c2538aae".HexToByteArray(), - "c9e1f8777685f54ba65c4e02915fd649ee1edcbf9c77ddf584b943d27efb86c3".HexToByteArray(), - "4274e92ed3bd02eb101baa5fb8ff7b96236830762d08273749fbb5166db8ab0b".HexToByteArray(), - "aa84c955bea04c7cee8f5bbbec97d25930fcaca363eed1b8cad37b931556d3e3".HexToByteArray(), - "d6a29c948677fb1f71aaf16debc3d071a4dd349458eb9e056dce3a000ff853da".HexToByteArray(), - "ba84bdb3d78367ca365016ac4bff9269576eb010f874c2967af73e0de5638de0".HexToByteArray(), - "1546c79951e3b541bc64d1957b565b7a2850fc87192c7b374aee6cfc69b9805e".HexToByteArray(), - "f119227d492ebe27fe9aae321980802454dfa64b2691efbe796c5075d5b07f62".HexToByteArray(), - "b8cf13d64818b32f96bbb585998b1bc9505f6a94055488e5a71fee9479c6f2a9".HexToByteArray(), - "1aaf459705b6afef2d7b83e3f181f1af55be0813daf55edce104cc59abc28ed7".HexToByteArray(), - "61ac185c8f520b5e3134953dc52ff292a40e1e96b088dab259558a9d240ec02f".HexToByteArray(), - "2da96e3154d7ec2329f787b73cb8a436b92d64cf3cc28e920d073279ea73b5f8".HexToByteArray(), - "1c4d72ce733b971b9ec4e24f37d733355f6f2ea635cc67ffb3e22748484df446".HexToByteArray(), - "2a6f89769f3272ac8c7a36a42a57627eca6b260ab2c76d8046a27d44d4034893".HexToByteArray(), - "f8d11df51a2cc113698ebf39a958fe81179d7d973d2044322771c0fe63f4d7c9".HexToByteArray(), - "f2287f17a4fa232dca5715c24a92f7112402a8101b9a7b276fb8c8f617376b90".HexToByteArray(), - "bb5ee510a4fda29cae30c97e7eee80569d3ec3598465f2d7e0674c395e0256e9".HexToByteArray(), - "647ab8c84365620d60f2523505d14bd230b5e650c96dee48be47770063ee7461".HexToByteArray(), - "34b06018fcc33ba6ebb01198d785b0629fbdc5d1948f688059158f053093f08b".HexToByteArray(), - "ff58b258dab0d7f36a2908e6c75229ce308d34806289c912a1a5f39a5aa71f9f".HexToByteArray(), - "232fc124803668a9f23b1c3bcb1134274303f5c0e1b0e27c9b6c7db59f0e2a4d".HexToByteArray(), - "27a0797cc5b042ba4c11e72a9555d13a67f00161550b32ede0511718b22dbc2c".HexToByteArray() - }; - - var merkleTree = new MerkleRoot(hashlist); - var expected = "871714dcbae6c8193a2bb9b2a69fe1c0440399f38d94b3a0f1b447275a29978a".HexToByteArray(); - - merkleTree.Root.Bytes.Should().Equal(expected); - } - } -} diff --git a/src/Tests/Crypto/Merkle/MerkleTreeTests.cs b/src/Tests/Cryptology/Merkle/MerkleTreeTests.cs similarity index 99% rename from src/Tests/Crypto/Merkle/MerkleTreeTests.cs rename to src/Tests/Cryptology/Merkle/MerkleTreeTests.cs index 98fc947c7..581f14c17 100644 --- a/src/Tests/Crypto/Merkle/MerkleTreeTests.cs +++ b/src/Tests/Cryptology/Merkle/MerkleTreeTests.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -22,16 +22,16 @@ #endregion using System.Linq; -using Coinium.Crypto.Merkle; -using Coinium.Daemon; -using Coinium.Daemon.Responses; -using Coinium.Transactions.Utils; -using Coinium.Utils.Extensions; +using CoiniumServ.Cryptology.Merkle; +using CoiniumServ.Daemon; +using CoiniumServ.Daemon.Responses; +using CoiniumServ.Transactions.Utils; +using CoiniumServ.Utils.Extensions; using Newtonsoft.Json; using Should.Fluent; using Xunit; -namespace Tests.Crypto.Merkle +namespace CoiniumServ.Tests.Cryptology.Merkle { public class MerkleTreeTests { diff --git a/src/Tests/Daemon/BlockTemplateTests.cs b/src/Tests/Daemon/BlockTemplateTests.cs index a3adddc0c..217dcca5c 100644 --- a/src/Tests/Daemon/BlockTemplateTests.cs +++ b/src/Tests/Daemon/BlockTemplateTests.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -22,8 +22,8 @@ #endregion using System.Collections.Generic; -using Coinium.Daemon; -using Coinium.Daemon.Responses; +using CoiniumServ.Daemon; +using CoiniumServ.Daemon.Responses; using Newtonsoft.Json; using Should.Fluent; using Xunit; @@ -72,7 +72,7 @@ } */ -namespace Tests.Daemon +namespace CoiniumServ.Tests.Daemon { public class BlockTemplateTests { diff --git a/src/Tests/Server/Stratum/Notifications/JobTests.cs b/src/Tests/Jobs/JobTests.cs similarity index 88% rename from src/Tests/Server/Stratum/Notifications/JobTests.cs rename to src/Tests/Jobs/JobTests.cs index 2531a68cd..64e7010f9 100644 --- a/src/Tests/Server/Stratum/Notifications/JobTests.cs +++ b/src/Tests/Jobs/JobTests.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,19 +20,21 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion + using System; +using System.Collections.Generic; using System.Linq; -using Coinium.Crypto.Algorithms; -using Coinium.Daemon; -using Coinium.Daemon.Responses; -using Coinium.Mining.Jobs; -using Coinium.Server.Stratum.Notifications; -using Coinium.Transactions; -using Coinium.Transactions.Script; -using Should.Fluent; -using Xunit; +using CoiniumServ.Cryptology.Algorithms; +using CoiniumServ.Daemon; +using CoiniumServ.Daemon.Responses; +using CoiniumServ.Jobs; +using CoiniumServ.Payments; +using CoiniumServ.Transactions; +using CoiniumServ.Transactions.Script; using Newtonsoft.Json; using NSubstitute; +using Should.Fluent; +using Xunit; /* sample data previousblockhash: 22a9174d9db64f1919febc9577167764c301b755768b675291f7d34454561e9e previousblockhashreversed: 54561e9e91f7d344768b6752c301b7557716776419febc959db64f1922a9174d @@ -80,7 +82,7 @@ ] */ -namespace Tests.Server.Stratum.Notifications +namespace CoiniumServ.Tests.Jobs { public class JobTests { @@ -117,24 +119,31 @@ public JobTests() "/nodeStratum/"); // outputs - _outputs = new Outputs(_daemonClient); + _outputs = Substitute.For(_daemonClient); double blockReward = 5000000000; // the amount rewarded by the block. - // sample recipient - const string recipient = "mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji"; + // sample reward recipient + var rewardsConfig = Substitute.For(); var amount = blockReward * 0.01; blockReward -= amount; - _outputs.AddRecipient(recipient, amount); + var rewards = new Dictionary { {"mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji", (float) amount} }; + + rewardsConfig.GetEnumerator().Returns(rewards.GetEnumerator()); + foreach (var pair in rewards) + { + _outputs.AddRecipient(pair.Key, pair.Value); + } // sample pool wallet - const string poolWallet = "mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq"; - _outputs.AddPool(poolWallet, blockReward); + var walletConfig = Substitute.For(); + walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq"); + _outputs.AddPoolWallet(walletConfig.Adress, blockReward); // job counter _jobCounter = Substitute.For(); // generation transaction. - _generationTransaction = new GenerationTransaction(_extraNonce, _daemonClient, _blockTemplate); + _generationTransaction = new GenerationTransaction(_extraNonce, _daemonClient, _blockTemplate, walletConfig, rewardsConfig); _generationTransaction.Inputs.First().SignatureScript = _signatureScript; _generationTransaction.Outputs = _outputs; _generationTransaction.Create(); diff --git a/src/Tests/Mining/Pools/PoolTests.cs b/src/Tests/Mining/Pools/PoolTests.cs deleted file mode 100644 index 338e19688..000000000 --- a/src/Tests/Mining/Pools/PoolTests.cs +++ /dev/null @@ -1,412 +0,0 @@ -#region License -// -// CoiniumServ - Crypto Currency Mining Pool Server Software -// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ -// -// This software is dual-licensed: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// For the terms of this license, see licenses/gpl_v3.txt. -// -// Alternatively, you can license this software under a commercial -// license or white-label it as set out in licenses/commercial.txt. -// -#endregion -using System; -using Coinium.Crypto.Algorithms; -using Coinium.Daemon; -using Coinium.Mining.Jobs.Manager; -using Coinium.Mining.Jobs.Tracker; -using Coinium.Mining.Miners; -using Coinium.Mining.Pools.Config; -using Coinium.Mining.Shares; -using Coinium.Persistance; -using Coinium.Server; -using Coinium.Service; -using Coinium.Utils.Configuration; -using NSubstitute; -using Should.Fluent; -using Xunit; - -namespace Tests.Mining.Pools -{ - public class PoolTests - { - // factory mocks - private readonly IServerFactory _serverFactory; - private readonly IServiceFactory _serviceFactory; - private readonly IJobManagerFactory _jobManagerFactory; - private readonly IJobTrackerFactory _jobTrackerFactory; - private readonly IShareManagerFactory _shareManagerFactory; - private readonly IHashAlgorithmFactory _hashAlgorithmFactory; - private readonly IMinerManagerFactory _minerManagerFactory; - private readonly IStorageFactory _storageManagerFactory; - private readonly IGlobalConfigFactory _globalConfigFactory; - - // object mocks. - private readonly IDaemonClient _daemonClient; - private readonly IMinerManager _minerManager; - private readonly IJobManager _jobManager; - private readonly IJobTracker _jobTracker; - private readonly IShareManager _shareManager; - private readonly IStorage _storage; - private readonly IMiningServer _miningServer; - private readonly IRpcService _rpcService; - - /// - /// Initialize mock objects. - /// - public PoolTests() - { - _jobManagerFactory = Substitute.For(); - _jobTrackerFactory = Substitute.For(); - _hashAlgorithmFactory = Substitute.For(); - _shareManagerFactory = Substitute.For(); - _minerManagerFactory = Substitute.For(); - _serverFactory = Substitute.For(); - _serviceFactory = Substitute.For(); - _storageManagerFactory = Substitute.For(); - _globalConfigFactory = Substitute.For(); - - _daemonClient = Substitute.For(); - _minerManager = Substitute.For(); - _jobManager = Substitute.For(); - _jobTracker = Substitute.For(); - _shareManager = Substitute.For(); - _miningServer = Substitute.For(); - _rpcService = Substitute.For(); - _storage = Substitute.For(); - } - - /// - /// Tests pool constructor with all valid parameters. Should succeed. - /// - [Fact] - public void ConstructorTest_NonNullParams_ShouldSucceed() - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - _serviceFactory, - _daemonClient, - _minerManagerFactory, - _jobTrackerFactory, - _jobManagerFactory, - _shareManagerFactory, - _storageManagerFactory, - _globalConfigFactory); - - pool.Should().Not.Be.Null(); - pool.InstanceId.Should().Be.GreaterThan((UInt32)0); - } - - /// - /// Tests pool constructor with null HashAlgorithm, should trow exception. - /// - [Fact] - public void ConstructorTest_NullHashAlgorithmFactory_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - null, - _serverFactory, - _serviceFactory, - _daemonClient, - _minerManagerFactory, - _jobTrackerFactory, - _jobManagerFactory, - _shareManagerFactory, - _storageManagerFactory, - _globalConfigFactory); - }); - - ex.Message.Should().Contain("IHashAlgorithmFactory"); - } - - /// - /// Tests pool constructor with null ServerFactory, should trow exception. - /// - [Fact] - public void ConstructorTest_NullServerFactory_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - null, - _serviceFactory, - _daemonClient, - _minerManagerFactory, - _jobTrackerFactory, - _jobManagerFactory, - _shareManagerFactory, - _storageManagerFactory, - _globalConfigFactory); - }); - - ex.Message.Should().Contain("IServerFactory"); - } - - /// - /// Tests pool constructor with null ServiceFactory, should trow exception. - /// - [Fact] - public void ConstructorTest_NullServiceFactory_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - null, - _daemonClient, - _minerManagerFactory, - _jobTrackerFactory, - _jobManagerFactory, - _shareManagerFactory, - _storageManagerFactory, - _globalConfigFactory); - }); - - ex.Message.Should().Contain("IServiceFactory"); - } - - /// - /// Tests pool constructor with null DaemonClient, should trow exception. - /// - [Fact] - public void ConstructorTest_NullDaemonClient_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - _serviceFactory, - null, - _minerManagerFactory, - _jobTrackerFactory, - _jobManagerFactory, - _shareManagerFactory, - _storageManagerFactory, - _globalConfigFactory); - }); - - ex.Message.Should().Contain("IDaemonClient"); - } - - /// - /// Tests pool constructor with null IMinerManagerFactory, should trow exception. - /// - [Fact] - public void ConstructorTest_NullMinerManagerFactory_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - _serviceFactory, - _daemonClient, - null, - _jobTrackerFactory, - _jobManagerFactory, - _shareManagerFactory, - _storageManagerFactory, - _globalConfigFactory); - }); - - ex.Message.Should().Contain("IMinerManagerFactory"); - } - - /// - /// Tests pool constructor with null JobManager, should trow exception. - /// - [Fact] - public void ConstructorTest_NullJobTrackerFactory_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - _serviceFactory, - _daemonClient, - _minerManagerFactory, - null, - _jobManagerFactory, - _shareManagerFactory, - _storageManagerFactory, - _globalConfigFactory); - }); - - ex.Message.Should().Contain("IJobTrackerFactory"); - } - - /// - /// Tests pool constructor with null JobManager, should trow exception. - /// - [Fact] - public void ConstructorTest_NullJobManagerFactory_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - _serviceFactory, - _daemonClient, - _minerManagerFactory, - _jobTrackerFactory, - null, - _shareManagerFactory, - _storageManagerFactory, - _globalConfigFactory); - }); - - ex.Message.Should().Contain("IJobManagerFactory"); - } - - /// - /// Tests pool constructor with null ShareManager, should trow exception. - /// - [Fact] - public void ConstructorTest_NullShareManagerFactory_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - _serviceFactory, - _daemonClient, - _minerManagerFactory, - _jobTrackerFactory, - _jobManagerFactory, - null, - _storageManagerFactory, - _globalConfigFactory); - }); - - ex.Message.Should().Contain("IShareManagerFactory"); - } - - /// - /// Tests pool constructor with null StorageFactory, should trow exception. - /// - [Fact] - public void ConstructorTest_NullStorageFactory_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - _serviceFactory, - _daemonClient, - _minerManagerFactory, - _jobTrackerFactory, - _jobManagerFactory, - _shareManagerFactory, - null, - _globalConfigFactory); - }); - - ex.Message.Should().Contain("IStorageFactory"); - } - - /// - /// Tests pool constructor with null GlobalConfigFactory, should trow exception. - /// - [Fact] - public void ConstructorTest_NullStorageManagerFactory_ShouldThrow() - { - Exception ex = Assert.Throws(() => - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - _serviceFactory, - _daemonClient, - _minerManagerFactory, - _jobTrackerFactory, - _jobManagerFactory, - _shareManagerFactory, - _storageManagerFactory, - null); - }); - - ex.Message.Should().Contain("IGlobalConfigFactory"); - } - - /// - /// Initializes pool with all valid parameters, should succeed. - /// - [Fact] - public void InitializationTest_NonNullParams_ShouldSuccess() - { - var pool = new Coinium.Mining.Pools.Pool( - _hashAlgorithmFactory, - _serverFactory, - _serviceFactory, - _daemonClient, - _minerManagerFactory, - _jobTrackerFactory, - _jobManagerFactory, - _shareManagerFactory, - _storageManagerFactory, - _globalConfigFactory); - - pool.Should().Not.Be.Null(); - pool.InstanceId.Should().Be.GreaterThan((UInt32)0); - - // pool-config mockup. - var config = Substitute.For(); - config.Daemon.Valid.Returns(true); - - // initialize hash algorithm - var hashAlgorithm = Substitute.For(); - _hashAlgorithmFactory.Get(config.Coin.Algorithm).Returns(hashAlgorithm); - - // initialize the miner manager. - _minerManagerFactory.Get(_daemonClient); - - // initialize storage manager - _storageManagerFactory.Get(Storages.Redis); - - // initialize the job tracker - _jobTrackerFactory.Get(); - - // initialize share manager. - _shareManagerFactory.Get(_daemonClient, _jobTracker, _storage).Returns(_shareManager); - - // initalize job manager. - _jobManagerFactory.Get(_daemonClient, _jobTracker, _shareManager, _minerManager, hashAlgorithm).Returns(_jobManager); - _jobManager.Initialize(pool.InstanceId); - - // init daemon client - _daemonClient.Initialize(config.Daemon); - - // init server - _serverFactory.Get(Services.Stratum, pool, _minerManager, _jobManager).Returns(_miningServer); - - // init service - _serviceFactory.Get(Services.Stratum, _shareManager, _daemonClient).Returns(_rpcService); - - // initalize the server. - _miningServer.Initialize(config.Stratum); - - // initialize the pool. - pool.Initialize(config); - } - } -} diff --git a/src/Tests/Pools/PoolTests.cs b/src/Tests/Pools/PoolTests.cs new file mode 100644 index 000000000..c8cb5ee39 --- /dev/null +++ b/src/Tests/Pools/PoolTests.cs @@ -0,0 +1,95 @@ +#region License +// +// CoiniumServ - Crypto Currency Mining Pool Server Software +// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ +// +// This software is dual-licensed: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// For the terms of this license, see licenses/gpl_v3.txt. +// +// Alternatively, you can license this software under a commercial +// license or white-label it as set out in licenses/commercial.txt. +// +#endregion + +using System; +using CoiniumServ.Daemon; +using CoiniumServ.Daemon.Responses; +using CoiniumServ.Factories; +using CoiniumServ.Pools; +using CoiniumServ.Pools.Config; +using NSubstitute; +using Should.Fluent; +using Xunit; + +namespace CoiniumServ.Tests.Pools +{ + public class PoolTests + { + // object mocks. + private readonly IObjectFactory _objectFactory; + private readonly IDaemonClient _daemonClient; + private readonly IPoolConfig _config; + + /// + /// Initialize mock objects. + /// + public PoolTests() + { + // factory mockup. + _objectFactory = Substitute.For(); + + // pool-config mockup. + _config = Substitute.For(); + _config.Daemon.Valid.Returns(true); + + // daemon client mockup. + _daemonClient = _objectFactory.GetDaemonClient(_config); + _daemonClient.GetInfo().Returns(new Info()); + _daemonClient.GetMiningInfo().Returns(new MiningInfo()); + } + + + /// + /// Tests pool constructor with all valid parameters. Should succeed. + /// + [Fact] + public void ConstructorTest_NonNullParams_ShouldSuccess() + { + var pool = new Pool(_config, _objectFactory); // create the pool instance. + + pool.Should().Not.Be.Null(); + pool.InstanceId.Should().Be.GreaterThan((UInt32)0); // pool should be already created an instance id. + } + + /// + /// Tests pool constructor with null paramets and expects exceptions being thronw. + /// + [Fact] + public void ConstructorTest_NullParams_ShouldThrowException() + { + var configException = Assert.Throws(() => + { + var pool = new Pool(null, _objectFactory); + }); + + configException.Message.Should().Contain("poolConfig"); + + var factoryException = Assert.Throws(() => + { + var pool = new Pool(_config, null); + }); + + factoryException.Message.Should().Contain("objectFactory"); + } + } +} diff --git a/src/Tests/Properties/AssemblyInfo.cs b/src/Tests/Properties/AssemblyInfo.cs index 17c611d10..5bd928249 100644 --- a/src/Tests/Properties/AssemblyInfo.cs +++ b/src/Tests/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/Tests/Mining/Shares/ShareTests.cs b/src/Tests/Shares/ShareTests.cs similarity index 94% rename from src/Tests/Mining/Shares/ShareTests.cs rename to src/Tests/Shares/ShareTests.cs index 617772c17..716d70cf3 100644 --- a/src/Tests/Mining/Shares/ShareTests.cs +++ b/src/Tests/Shares/ShareTests.cs @@ -2,7 +2,7 @@ // // CoiniumServ - Crypto Currency Mining Pool Server Software // Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org -// https://github.com/CoiniumServ/CoiniumServ +// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ // // This software is dual-licensed: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,30 +20,29 @@ // license or white-label it as set out in licenses/commercial.txt. // #endregion + using System; +using System.Collections.Generic; using System.Linq; -using Coinium.Coin.Config; -using Coinium.Crypto.Algorithms; -using Coinium.Daemon; -using Coinium.Daemon.Responses; -using Coinium.Mining.Jobs; -using Coinium.Mining.Jobs.Manager; -using Coinium.Mining.Jobs.Tracker; -using Coinium.Mining.Miners; -using Coinium.Mining.Pools; -using Coinium.Mining.Shares; -using Coinium.Server.Stratum; -using Coinium.Server.Stratum.Notifications; -using Coinium.Transactions; -using Coinium.Transactions.Script; -using Coinium.Utils.Extensions; -using Coinium.Utils.Numerics; +using CoiniumServ.Cryptology.Algorithms; +using CoiniumServ.Daemon; +using CoiniumServ.Daemon.Responses; +using CoiniumServ.Jobs; +using CoiniumServ.Jobs.Manager; +using CoiniumServ.Jobs.Tracker; +using CoiniumServ.Payments; +using CoiniumServ.Server.Mining.Stratum; +using CoiniumServ.Shares; +using CoiniumServ.Transactions; +using CoiniumServ.Transactions.Script; +using CoiniumServ.Utils.Extensions; +using CoiniumServ.Utils.Numerics; using Newtonsoft.Json; using NSubstitute; using Should.Fluent; using Xunit; -namespace Tests.Mining.Shares +namespace CoiniumServ.Tests.Shares { public class ShareTests { @@ -122,18 +121,25 @@ public ShareTests() _outputs = Substitute.For(_daemonClient); double blockReward = 5000000000; // the amount rewarded by the block. - // sample recipient - const string recipient = "mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji"; + // sample reward recipient + var rewardsConfig = Substitute.For(); var amount = blockReward * 0.01; blockReward -= amount; - _outputs.AddRecipient(recipient, amount); + var rewards = new Dictionary { { "mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji", (float)amount } }; + + rewardsConfig.GetEnumerator().Returns(rewards.GetEnumerator()); + foreach (var pair in rewards) + { + _outputs.AddRecipient(pair.Key, pair.Value); + } // sample pool wallet - const string poolWallet = "mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq"; - _outputs.AddPool(poolWallet, blockReward); + var walletConfig = Substitute.For(); + walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq"); + _outputs.AddPoolWallet(walletConfig.Adress, blockReward); // generation transaction - _generationTransaction = Substitute.For(_extraNonce, _daemonClient, _blockTemplate, false); + _generationTransaction = Substitute.For(_extraNonce, _daemonClient, _blockTemplate, walletConfig,rewardsConfig, false); _generationTransaction.Inputs.First().SignatureScript = _signatureScript; _generationTransaction.Outputs = _outputs; _generationTransaction.Create(); @@ -153,7 +159,7 @@ public ShareTests() // the job manager. _jobManager = Substitute.For(); - _jobManager.ExtraNonce.Current.Returns((UInt32)0x58000000); + _jobManager.ExtraNonce.Next().Returns((UInt32)0x58000000); // coin config _miner = Substitute.For(); diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index e9ac1f3b3..dcc7b929a 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -7,9 +7,9 @@ {73CE2C0A-12E6-42FD-8021-C75827D014E3} Library Properties - Tests + CoiniumServ.Tests CoiniumServ.Tests - v4.0 + v4.5 512 ..\..\build\ true @@ -23,6 +23,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -31,52 +32,31 @@ TRACE prompt 4 + false False ..\..\build\packages\BouncyCastle.1.7.0\lib\Net40-Client\BouncyCastle.Crypto.dll - - ..\..\build\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll - - - ..\..\build\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll - - - ..\..\build\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll - - - False - ..\..\build\packages\Nancy.0.23.0\lib\net40\Nancy.dll - False - ..\..\build\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll + ..\..\build\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll - - ..\..\build\packages\NSubstitute.1.7.2.0\lib\NET40\NSubstitute.dll + + False + ..\..\build\packages\NSubstitute.1.7.2.0\lib\NET45\NSubstitute.dll - + + False ..\..\build\packages\ShouldFluent.1.1.19\lib\Should.Fluent.dll - - ..\..\build\packages\StackExchange.Redis.1.0.312\lib\net40\StackExchange.Redis.dll - - - ..\..\build\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll - - - ..\..\build\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll - - - ..\..\build\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll - - + + False ..\..\build\packages\xunit.1.9.2\lib\net20\xunit.dll @@ -85,16 +65,15 @@ - - + - - + + - + @@ -116,6 +95,7 @@ + @@ -124,11 +104,6 @@ - - - - -