Skip to content

Commit

Permalink
Now shows fully correct mining algo info in getinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki Verloren committed Nov 13, 2018
1 parent d8ff3de commit 40178d3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
File renamed without changes.
8 changes: 6 additions & 2 deletions cmd/sac/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ func main() {

// Wait until the node has fully synced up to the local
// btcd node.
for !spvNode.IsCurrent() {
time.Sleep(time.Millisecond * 100)
for {
if spvNode.IsCurrent() {
fmt.Println("Node is now current")
fmt.Println(spvNode.BestBlock())
}
time.Sleep(time.Millisecond * 10000)
// fmt.Println(spvNode.NetTotals())
}

Expand Down
10 changes: 5 additions & 5 deletions neutrino/blockmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2357,11 +2357,11 @@ func (b *blockManager) handleHeadersMsg(hmsg *headersMsg) {
// checkHeaderSanity checks the PoW, and timestamp of a block header.
func (b *blockManager) checkHeaderSanity(blockHeader *wire.BlockHeader,
maxTimestamp time.Time, reorgAttempt bool) error {
hv := blockHeader.Version
if !=514 {
hv = 2
}
diff, err := b.calcNextRequiredDifficulty(
hv := blockHeader.Version
if hv != 514 {
hv = 2
}
diff, err := b.calcNextRequiredDifficulty(
blockHeader.Timestamp, reorgAttempt, hv)
// fmt.Printf("DIFFICULTY %08x\n", diff)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,9 @@ func LoadConfig() (*Config, []string, error) {
// Set the mining algorithm correctly, default to sha256d if unrecognised
switch Cfg.Algo {
case "scrypt":

Cfg.Algo = "scrypt"
case "sha256d":
Cfg.Algo = "sha256d"
default:
Cfg.Algo = "sha256d"
}
Expand Down
20 changes: 18 additions & 2 deletions server/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2339,7 +2339,7 @@ func HandleGetInfo(s *RPCServer, cmd interface{}, closeChan <-chan struct{}) (in
ver = 2
}

gen := int32(s.cfg.ChainParams.GenerationAlgo)
// gen := int32(s.cfg.ChainParams.GenerationAlgo)

var shabits, scryptbits uint32
if ver != 514 {
Expand Down Expand Up @@ -2383,14 +2383,30 @@ func HandleGetInfo(s *RPCServer, cmd interface{}, closeChan <-chan struct{}) (in
}
}

bestBits := best.Bits
algoname := "sha256d"
algoid := int32(0)
algover := int32(2)
fmt.Println(algoname, algoid)
switch s.cfg.AlgoID {
case 514:
algoname = "scrypt"
algoid = 1
algover = int32(514)
bestBits = scryptbits
default:
}

ret := &JSON.InfoChainResult{
Version: int32(1000000*AppMajor + 10000*AppMinor + 100*AppPatch),
ProtocolVersion: int32(maxProtocolVersion),
Blocks: best.Height,
TimeOffset: int64(s.cfg.TimeSource.Offset().Seconds()),
Connections: s.cfg.ConnMgr.ConnectedCount(),
Proxy: Cfg.Proxy,
Difficulty: GetDifficultyRatio(best.Bits, s.cfg.ChainParams, gen),
PowAlgoID: algoid,
PowAlgo: algoname,
Difficulty: GetDifficultyRatio(bestBits, s.cfg.ChainParams, algover),
DifficultySHA256D: GetDifficultyRatio(shabits, s.cfg.ChainParams, 2),
DifficultyScrypt: GetDifficultyRatio(scryptbits, s.cfg.ChainParams, 514),
TestNet: Cfg.TestNet3,
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,7 @@ func New(listenAddrs []string, db database.DB, chainParams *chaincfg.Params, int
AddrIndex: s.addrIndex,
CfIndex: s.cfIndex,
FeeEstimator: s.feeEstimator,
AlgoID: a,
})
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions server/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ type RPCServerConfig struct {
// The fee estimator keeps track of how long transactions are left in
// the mempool before they are mined into blocks.
FeeEstimator *mempool.FeeEstimator

AlgoID uint32
}

// RPCServerPeer represents a peer for use with the RPC server.
Expand Down

0 comments on commit 40178d3

Please sign in to comment.