0

I'm trying to extend clique and to add a signer programatically, my initial PoC looks something like this which i have placed into the snapshot.go file in clique, when i do this, compile and restard geth i get errors like this

    ERROR[06-22|14:21:01.550788] 
    ########## BAD BLOCK #########
    Chain config: {ChainID: 2018 Homestead: 1 DAO: <nil> DAOSupport: false EIP150: 2 EIP155: 3 EIP158: 3 Byzantium: 4 Constantinople: <nil> Engine: clique}

    Number: 33016
    Hash: 0x8a5fe26a802a4b47e61f9209135531e82b1209bc7a8ccc70d4636fc8ad9e8e69

    Error: invalid difficulty
    ##############################

    WARN [06-22|14:21:01.550861] Synchronisation failed, dropping peer    peer=70fbf40c8e416af6 err="retrieved hash chain is invalid"

here is my PoC

    stringAddress := "62ecc061160c145705388ab49984e0728beaae4c"
    address, err := hex.DecodeString(stringAddress)
    byteArrayAddress := common.BytesToAddress(address[:])

    for i, exists := range s.signers() {

        if hex.EncodeToString(exists[:]) != stringAddress {
            snap.Signers[byteArrayAddress] = struct{}{}
            if snap.cast(byteArrayAddress, true) {
                snap.Votes = append(snap.Votes, &Vote{
                    Signer:    signer,
                    Block:     number,
                    Address:   byteArrayAddress,
                    Authorize: true,
                })
            }
        }
        fmt.Println(i, " signers in action ", hex.EncodeToString(exists[:]))
    }

I have commented out the voting logic in this function so that voting can be solely controlled by me, i.e if this address is not in the current signers then append it to the signers array and give it full authorization to sign. Anyone able to point me in the right direction with this or validate that I am in the right place to implement such functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.