Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

optimize trojan chunk mining #2157

Open
mortelli opened this issue Apr 13, 2020 · 0 comments
Open

optimize trojan chunk mining #2157

mortelli opened this issue Apr 13, 2020 · 0 comments
Assignees
Labels
global pinning experimental implementation of global pinning

Comments

@mortelli
Copy link
Contributor

mortelli commented Apr 13, 2020

(issue stemming from unresolved thread in #2148)

@zelig's suggestion:

so here we can do parallelisation

func mine(f func(nonce []byte) (interface{}, bool)) (interface{}) {
    seeds := [8]uint32
    for i, _ := range seeds {
        seeds[i] = rand.Uint32()
    }
    initnonce := make([]byte, 32)
    for i:=0; i<32; i+=4 {
        binary.PutUint32(initnonce[i:i+4], seeds[i])
    }
    quit := make(chan struct{})
    result := make(chan interface{})
    for i:=0; i<8; i++ {
        nonce :=  make([]byte,32)
        copy(nonce, initnonce)
        go func(seed uint32) {
            for ;;seed++{
                binary.PutUint32(nonce[i:i+4], seed)
                if res, ok := f(nonce); ok {
                    result <- res
                    return
                }
                select {
                    case <- quit:
                    return
                    default:
                }
            }
        }(seeds[i])
    }
    defer close(quit)
    return <-result
}

see thread here


additionally, some sort of timeout should be implemented for the mining.

@mortelli mortelli added the global pinning experimental implementation of global pinning label Apr 13, 2020
@mortelli mortelli self-assigned this Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
global pinning experimental implementation of global pinning
Projects
None yet
Development

No branches or pull requests

1 participant