Bitcoin Forum
May 05, 2024, 12:06:53 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What is the block matched the request?  (Read 804 times)
lamuguo (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
May 31, 2011, 05:06:21 PM
 #1

The response of getwork request is:
data:00000001dfa9247a8ded0663ebb3b2ef9787044074ff42508190ef3a00001cc5000000000574128 7c1c19b9ecac6e56c6d20078da9e1ce40575900ad463ccc73ee71598c4de32f1e1a269421000000 0000000080000000000000000000000000000000000000000000000000000000000000000000000 0000000000080020000
hash1:0000000000000000000000000000000000000000000000000000000000000000000000800000000 0000000000000000000000000000000000000000000010000
target:0000000000000000000000000000000000000000000000219426000000000000
midstate:39f960097671413910bd7637b2f28c5c2231316e2b12d16f2f9be77a0f6c1df1

I can't find an answer by algorithm as below: (the algorithm is copied from gaeminer)

  public boolean scan(Work work, int start, int count) {
    SHA256 sha256 = new SHA256();

    int[] _data = decode(new int[16], work.getData().substring(128));
    int[] _midstate = decode(decode(new int[16], work.getHash1()), work.getMidstate());

    int[] __state, __data, __hash1, __hash;
    for (int nonce = start; nonce < start + count; nonce++) {
      _data[3] = nonce; // NONCE is _data[3]
      hashed++;
     
      if ((nonce & 0xFFFFF) == 13) {
        LOG.info("nonce = " + nonce);
      }

      __state = new int[_midstate.length];
      System.arraycopy(_midstate, 0, __state, 0, _midstate.length);
      __data = _data;

      sha256.processBlock(__state, __data);
      __hash1 = __state;

      __state = SHA256.initState();
      sha256.processBlock(__state, __hash1);
      __hash = __state;

      if (__hash[7] == 0) {
        work.setData(work.getData().substring(0, 128) + encode(__data));
        work.setNonce(nonce);
        return true;
      }
    }

    return false;
  }

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!