Zambonie, on 08 March 2015 - 02:53 PM, said:
So, trying to make a miner, asking Coss for help a little
From looking at other's code and Coss's help, I got this:
Get the latest block from
http://65.26.252.225...lastblock
combine that like miner address + block + nonce concatenated
hash with sha256.
then get the contents on the page "http://65.26.252.225/quest/dia/krist/?submitblock&address=myaddressthing&nonce=noncething
Something seems to be missing from here lol..
Someone
*cough*@cossacksson*cough* needs to make that guide on the internals of Krist, so that others can understand how stuff works and how to work with it..
That's almost it. Here's a bit more detail using pseudocode.
start:
nonce = 0
addr = "ks372l1pfa" // Or some other address
lastBlock = nodeget("lastblock")
addrWithBlock = concat(addr, lastBlock)
while true do
nonceString = tostring(nonce, 10)
toHash = concat(addrWBlock, nonceString)
hashBytes = sha256(toHash)
hashString = toLowerBase16(hashBytes)
subHash = substr(hashString, 12)
if(lexicographicallyLess(subHash, lastBlock)) {
nodeget(concat("submitblock&address=ks372l1pfa&nonce=", nonceString))
goto start
}
nonce++
end
nodeget(str) - Get the contents of the page whose url is the concatenation of "65.26.252.225/quest/dia/krist/?" with str.
concat(s1, s2) - Concatenate s1 with s2.
tostring(n, base) - Convert n to a string in some number base.
sha256(str) - Get the SHA-256 hash of str as an array of bytes.
toLowerBase16(bytes) - Convert a byte array to a hex string with lowercase a-f characters.
substr(str, n) - Get the first n characters of a string.
lexicographicallyLess(s1, s2) - Check if s1 is lexicographically less than s2. If s1 and s2 were words in a dictionary, return true if s1 would appear before s2 in that dictionary.
Example:
My address is "k3s72l1pfa"
The last block was "000000018600"
addrWithBlock = "k3s72l1pfa000000018600"
Let's try nonce = 1337
nonceString = "1337"
toHash = "k3s72l1pfa0000000186001337"
hashBytes = some weird garbage looking array of bytes
hashString = "
9433d0c8a2a8c982841c46a118c38c9f0cb989d487724c844fd8bbb361ef9baa"
subHash = "
9433d0c8a2a8"
Is the hash we found less than the last block?
In other words, is
9433d0c8a2a8 < 000000018600?
No, not even close. Rinse and repeat with another nonce until we find a good one.
This is just based off of what I've learned by looking at Grim's code and working on my own miner. Please let me know if anything is incorrect.