Skip to content

Commit

Permalink
Merge pull request #6 from Hansen333/testing
Browse files Browse the repository at this point in the history
Miner Stats Galore
  • Loading branch information
Hansen333 authored Jul 21, 2022
2 parents 17d1bc1 + 3ad3dca commit 2f7076c
Show file tree
Hide file tree
Showing 29 changed files with 1,841 additions and 476 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ cmd/dero-miner/dero-miner
cmd/derod/derod
cmd/dero-wallet-cli/dero-wallet-cli
cmd/*/*.log
cmd/*/*.txt
cmd/*/history/
cmd/*/history/*
cmd/dero-wallet-cli/*.db*
17 changes: 12 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
If you don't alredy know DERO - Check out [Dero git repo](https://github.com/deroproject/derohe)

* This is a Weaponized version of Dero Daemon, this is NOT the official release of DERO.
* Please use with causion, as with all weapons you may or may not hurt your self using this.
* Please use with caution, as with all weapons you may or may not hurt yourself or others using this.
* If all your minis get lost or your computer blows up, it's no my fault, you installed this.


* This modded DERO version is running and providing live stats for on the nodes below
* UK Node - https://dero-node.mysrv.cloud
* US Node - https://dero-node-us.mysrv.cloud
* Europe Node - https://dero-node.mysrv.cloud
* North America Node - https://dero-node-us.mysrv.cloud
* South Ammerica Node - https://dero-node-sa.mysrv.cloud

### Developers

* @Hansen333
* @Hansen33
* Address: dero1qy07h9mk6xxf2k4x0ymdpezvksjy0talskhpvqmat3xk3d9wczg5jqqvwl0sn
* @arodd
* Address: dero1qyss8jkqfkvp4vlxfx3l7f9rr7m55ff3q633ag8xemzv0el90m2j2qqy0te2c
Expand All @@ -23,7 +24,13 @@ If you don't alredy know DERO - Check out [Dero git repo](https://github.com/der
### Changes from official release includes

More Options, switches and buttons

* Miner (--text-mode) - no interactiveness, just mining and output update every 60 sec
* Active Miner Metrics - Node Guessing
* Miner Hashrate, Tagging and Orphan to Miner Reporting**
* Live mining stats including orphan counters.
* Wallet Socks Proxy Support and TOR Onion Support**
` --daemon-address vpilhs5wew52w75igez5fye2c572lccuo7l5emyxxvo53darwec6x7yd.onion:10102`
* BlocksIn/BlocksOut count in syncinfo - repurposed unused official counters
* AddressToName - command to look up names inside derod (using HarkerK code)
* Allow more than 31 incoming peers (will use max_peer option as limit)
* Miners list and mining performance stats
Expand Down
72 changes: 66 additions & 6 deletions block/miniblockdag.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"sort"
"sync"
"time"

"github.com/deroproject/derohe/config"
)

type MiniBlocksCollection struct {
Expand All @@ -44,20 +46,64 @@ var MyOrphanBlocks = make(map[string][]MiniBlock)

func AddBlockToMyCollection(mbl MiniBlock, miner string) {
miner_mini_mutex.Lock()
defer miner_mini_mutex.Unlock()

MyBlocks[miner] = append(MyBlocks[miner], mbl)
miner_mini_mutex.Unlock()

}

var LastPurgeHeight uint64 = 0
var MiniBlockCounterMap = make(map[string]time.Time)
var OrphanMiniCounterMap = make(map[string]time.Time)
var OrphanMiniCounter100 = make(map[string]int64)
var OrphanBlocks = make(map[string]int64)

func GetMyOrphansList() map[string]map[string]uint64 {

miner_mini_mutex.Lock()
defer miner_mini_mutex.Unlock()

var OrphanList = make(map[string]map[string]uint64)

for miner, _ := range MyOrphanBlocks {

var stat = make(map[string]uint64)

for _, mbl := range MyOrphanBlocks[miner] {

stat[mbl.GetHash().String()] = mbl.Height

OrphanList[miner] = stat
}
}

return OrphanList
}

func GetMinerOrphanCount(Address string) uint64 {

miner_mini_mutex.Lock()
defer miner_mini_mutex.Unlock()

_, found := MyOrphanBlocks[Address]
if found {
return uint64(len(MyOrphanBlocks[Address]))
}

return 0
}

func BlockRateCount(height int64) (int, int, float64, int) {

orphan_block_count_mutex.Lock()
defer orphan_block_count_mutex.Unlock()

for x := range OrphanBlocks {
if OrphanBlocks[x]+config.RunningConfig.NetworkStatsKeepCount < height {
delete(OrphanBlocks, x)
}
}

for x := range OrphanMiniCounter100 {
if OrphanMiniCounter100[x]+100 < height {
delete(OrphanMiniCounter100, x)
Expand Down Expand Up @@ -85,6 +131,17 @@ func BlockRateCount(height int64) (int, int, float64, int) {
return len(OrphanMiniCounterMap), len(MiniBlockCounterMap), orphan_rate, len(OrphanMiniCounter100)
}

func IsBlockOrphan(block_hash string) bool {

orphan_block_count_mutex.Lock()
defer orphan_block_count_mutex.Unlock()

_, x := OrphanBlocks[block_hash]

return x

}

// purge all heights less than this height
func (c *MiniBlocksCollection) PurgeHeight(minis []MiniBlock, height int64) (purge_count int) {
if height < 0 {
Expand All @@ -93,6 +150,9 @@ func (c *MiniBlocksCollection) PurgeHeight(minis []MiniBlock, height int64) (pur
c.Lock()
defer c.Unlock()

orphan_block_count_mutex.Lock()
defer orphan_block_count_mutex.Unlock()

for k, _ := range c.Collection {
if k.Height <= uint64(height) {
purge_count++
Expand Down Expand Up @@ -122,11 +182,11 @@ func (c *MiniBlocksCollection) PurgeHeight(minis []MiniBlock, height int64) (pur
if !match {

// Log lost minis
orphan_block_count_mutex.Lock()

i := time.Now()
OrphanMiniCounterMap[fmt.Sprintf("%s", mbl.GetHash())] = i
OrphanMiniCounter100[fmt.Sprintf("%s", mbl.GetHash())] = height
orphan_block_count_mutex.Unlock()
OrphanMiniCounterMap[mbl.GetHash().String()] = i
OrphanMiniCounter100[mbl.GetHash().String()] = height
OrphanBlocks[mbl.GetHash().String()] = height

miner_mini_mutex.Lock()
// Check my minis, if any are orphaned
Expand Down Expand Up @@ -206,7 +266,7 @@ func (c *MiniBlocksCollection) InsertMiniBlock(mbl MiniBlock) (err error, result

orphan_block_count_mutex.Lock()
i := time.Now()
MiniBlockCounterMap[fmt.Sprintf("%s", mbl.GetHash())] = i
MiniBlockCounterMap[mbl.GetHash().String()] = i
orphan_block_count_mutex.Unlock()

c.Collection[mbl.GetKey()] = append(c.Collection[mbl.GetKey()], mbl)
Expand Down
41 changes: 20 additions & 21 deletions blockchain/miner_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,29 @@

package blockchain

import "fmt"
import "bytes"
import "sort"
import "sync"
import "runtime/debug"
import "encoding/binary"

import "golang.org/x/xerrors"
import "golang.org/x/time/rate"
import "golang.org/x/crypto/sha3"
import (
"bytes"
"encoding/binary"
"fmt"
"runtime/debug"
"sort"
"sync"

"github.com/deroproject/derohe/block"
"github.com/deroproject/derohe/config"
"github.com/deroproject/derohe/cryptography/crypto"
"github.com/deroproject/derohe/errormsg"
"github.com/deroproject/derohe/globals"
"github.com/deroproject/derohe/rpc"
"github.com/deroproject/derohe/transaction"
"github.com/deroproject/graviton"
"golang.org/x/crypto/sha3"
"golang.org/x/time/rate"
"golang.org/x/xerrors"
)

// this file creates the blobs which can be used to mine new blocks

import "github.com/deroproject/derohe/block"
import "github.com/deroproject/derohe/config"
import "github.com/deroproject/derohe/cryptography/crypto"
import "github.com/deroproject/derohe/globals"
import "github.com/deroproject/derohe/rpc"

import "github.com/deroproject/derohe/errormsg"
import "github.com/deroproject/derohe/transaction"

import "github.com/deroproject/graviton"

const TX_VALIDITY_HEIGHT = 11

// structure used to rank/sort blocks on a number of factors
Expand Down
Loading

0 comments on commit 2f7076c

Please sign in to comment.