getNExtVerifier returns the id of next verifier. ID is determined by the hash of previous block.
(previousBlock, currentBlock StorageProofBlock)
| 70 | // getNExtVerifier returns the id of next verifier. |
| 71 | // ID is determined by the hash of previous block. |
| 72 | func getNextVerifier(previousBlock, currentBlock StorageProofBlock) (int32, error) { |
| 73 | // check if block is valid |
| 74 | if len(previousBlock.ID) <= 0 { |
| 75 | return -1, errors.New("invalid previous block") |
| 76 | } |
| 77 | if len(currentBlock.Nodes) <= 0 { |
| 78 | return -1, errors.New("invalid current block") |
| 79 | } |
| 80 | verifier := int32(hash.FNVHash32uint([]byte(previousBlock.ID))) % int32(len(currentBlock.Nodes)) |
| 81 | |
| 82 | return verifier, nil |
| 83 | } |
| 84 | |
| 85 | // selectRecord returns nth record in the table from the database. |
| 86 | func selectRecord(n int32) string { |