Documentation
¶
Overview ¶
model contains data structures canonical to all layers in nuts-network
Index ¶
Constants ¶
const HashSize = 20
HashSize holds the size of hashes used on the network.
Variables ¶
This section is empty.
Functions ¶
func MarshalDocumentTime ¶ added in v0.15.3
MarshalDocumentTime converts a document's time.Time to unix nanoseconds.
func UnmarshalDocumentTime ¶ added in v0.15.3
UnmarshalDocumentTime converts a document's timestamp in unix nanoseconds to time.Time.
Types ¶
type Document ¶
type Document struct {
// Hash contains the hash of the document (which is calculated using its type, timestamp and contents).
Hash Hash
// Type contains a key describing what the document holds (e.g. 'nuts.node-info'). It is free format.
Type string
// Timestamp holds the moment the document was created. When serialized (for storage or transport on the network) it is converted to UTC and represented in Unix nanoseconds.
Timestamp time.Time
}
Document describes a document on the network.
type DocumentDescriptor ¶
type DocumentDescriptor struct {
Document
// HasContents indicates whether we have the contents of the document.
HasContents bool
// ConsistencyHash contains the actual consistency hash for the document.
ConsistencyHash Hash
}
DocumentDescriptor is just a Document with often-required properties added (HasContents indicator) to optimize access to the document storage.
type Hash ¶
Hash is a type that holds a hash used on the network.
func CalculateDocumentHash ¶
CalculateDocumentHash calculates the hash for a Document in a canonicalized manner.
func EmptyHash ¶
func EmptyHash() Hash
EmptyHash returns a Hash that is empty (initialized with zeros).
func MakeConsistencyHash ¶
MakeConsistencyHash calculates a consistency hash for the given 2 input Hashes and returns it.
func ParseHash ¶
ParseHash parses the given input string as Hash. If the input is invalid and can't be parsed as Hash, an error is returned.
func SliceToHash ¶ added in v0.15.2
SliceToHash converts a byte slice to a Hash, returning a copy.
func (Hash) Compare ¶ added in v0.15.2
Compare compares this Hash to another Hash using bytes.Compare.
type NodeID ¶
type NodeID string
NodeID is a self-proclaimed unique identifier for nodes on the network.