MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / getNextVerifier

Function getNextVerifier

sqlchain/storageproof.go:72–83  ·  view source on GitHub ↗

getNExtVerifier returns the id of next verifier. ID is determined by the hash of previous block.

(previousBlock, currentBlock StorageProofBlock)

Source from the content-addressed store, hash-verified

70// getNExtVerifier returns the id of next verifier.
71// ID is determined by the hash of previous block.
72func 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.
86func selectRecord(n int32) string {

Callers 1

TestGetNextVerifierFunction · 0.85

Calls 2

FNVHash32uintFunction · 0.92
NewMethod · 0.65

Tested by 1

TestGetNextVerifierFunction · 0.68