The public directory contains regular, unencrypted, structured data. This includes previous versions, metadata, symlinks, and so on. This lives in the top-level /public directory. All of the content is publicly viewable, including previous versions.
Data Layer
At the raw data layer, a public virtual node has the following shape:
1
dataVirtualNode-- could be paramaterized over protocol type later
2
=DirectoryNodeDirectory
3
|FileNodeFile
4
|SymlinkDNSLink
5
|MovedNodePath
6
|RawProtocolIPFSNode
7
8
dataFile=File
9
{metadata::Metadata
10
,rawContent::CID
11
}
12
13
dataDirectoryprotocol=Directory
14
{metadata::Metadata
15
,index::MapTextVirtualNode
16
}
17
18
dataMetadata=Metadata
19
{history::MaybeHistory
20
,unixMeta::UnixMeta
21
,wnfsVersion::SemVer
22
}
23
24
dataHistory=History
25
{previous::VirtualNode
26
,event::Event
27
}
28
29
dataUnixMeta=UnixMeta
30
{mtime::UTCTime
31
,ctime::UTCTime
32
,mode::UnixFileMode
33
,type_::UnixNodeType
34
}
35
36
dataIPFSNode=IPFSNode
37
{links::[(Text,RawProtocol)]
38
,data_::MaybeByteString
39
}
40
41
dataIPFSLink=IPFSLink
42
{name::Text
43
,hash::CID
44
,size::QuantityBytes
45
}
Copied!
The data layer strips out much of the above structure, boiling it down to a series of IPFSLinks. This is fundamentally achieved by a function:
1
serializeForProtcol::VirtualNode->IPFSNode
Copied!
In this function, much of the metadata is compacted into CBOR files, for efficiency and convenience with the IPFS-supported dag-cbor.
Here is an intermediate abstraction to help describe the layout:
1
dataIPFSSerialized=IPFSSerialized
2
{metadata::CBOR
3
,dagCache::CBOR
4
,previous::CID
5
,userland::Userland
6
}
7
8
dataUserland=Either[(Text,IPFSLink)]IPFSNode
Copied!
Note that links are NOT flattened into a single node. WNFS maintains a special separate namespace for userland. This is a 2-layer approach:
1
+———————————————————+
2
| |
3
| IPFSNode |
4
| |
5
| +———————+ |
6
| | Links | |
7
| +———————+ |
8
| / | | \ |
9
+————/——|———|——\————+
10
/ | | \
11
Prev | | Userland
12
/ | | \
13
/ dag.cbor | \
14
<——* | meta.cbor \
15
| | \
16
+————+ +————+ +———————————————+
17
|DATA| |DATA| | |
18
+————+ +————+ | IPFSNode |
19
| |
20
| +———————+ |
21
| | Links | <———— the directory index
22
| +———————+ |
23
| / | \ |
24
+———/———|———\———+
25
/ | \
26
... ... ...
Copied!
Note that the prev link SHOULD be reified in a protocol link rather than in the cache to ensure that the link is real, the file will never be dropped (if the root user breaks a layer), and make it faster to verify.
Write Access
Write access may be granted via UCAN. In this case, the platform-layer (pretty) path to the node is updatable arbitrarily, as are its nested contents. However, this necessitates updating the links in the Merkle structure above, as well as portions of metadata (such as size of contents). This is a rote mechanical procedure, and will be checked by the verifier.
It bears repeating that while this does create updated parent nodes, it will be handled mechanically by the WNFS client. The verifier is able to easily and mechanically confirm these updates, and will reject them if submitted incorrectly.
Concurrency
Concurrent writes on WNFS never overwrite each other. Multiple branches of history are allowed — and persisted — as long as they are eventually merged. See the Consistency section for more.