computeLayerHash
computeLayerHash(
fs):Promise<string>
Defined in: packages/core/src/kernel/layer.ts:379
Compute the canonical SHA-256 content hash for a frozen memoryFS.
Parameters
Section titled “Parameters”Frozen memoryFS to hash.
Returns
Section titled “Returns”Promise<string>
Hex SHA-256 of the canonical line format.
Remarks
Section titled “Remarks”Walks the FS in sorted, recursive order and emits one line per entry:
- file:
file|<path>|<size>|<mode>|<content-sha256> - dir:
dir|<path>|<mode> - symlink:
symlink|<path>|<target> - whiteout:
whiteout|<originalPath>(so deletions affect identity)
Instance-specific fields (ino, dev) are excluded — two memoryFS
instances with the same content produce the same hash. This is the
content-hash input to chainAwareId, not the layer id itself.
Example
Section titled “Example”import { computeLayerHash } from '@fishnet/core'
const contentHash = await computeLayerHash(frozenFs)