-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3625 from Agoric/3442-activity-hash
expose hash of kernel state changes as "activityhash"
- Loading branch information
Showing
17 changed files
with
399 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { assert } from '@agoric/assert'; | ||
|
||
import { createHash } from 'crypto'; | ||
|
||
/** | ||
* @typedef { (initial: string?) => { | ||
* add: (more: string) => void, | ||
* finish: () => string, | ||
* } | ||
* } CreateSHA256 | ||
*/ | ||
|
||
/** @type { CreateSHA256 } */ | ||
function createSHA256(initial = undefined) { | ||
const hash = createHash('sha256'); | ||
let done = false; | ||
function add(more) { | ||
assert(!done); | ||
hash.update(more); | ||
} | ||
function finish() { | ||
assert(!done); | ||
done = true; | ||
return hash.digest('hex'); | ||
} | ||
if (initial) { | ||
add(initial); | ||
} | ||
return harden({ add, finish }); | ||
} | ||
harden(createSHA256); | ||
export { createSHA256 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.