ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.18k stars 3.01k forks source link

Immutable Merkledag #1022

Closed krl closed 8 years ago

krl commented 9 years ago

"we should start thinking about making Merkledag nodes immutable and having a separate type for changing them"

I'd be interested in having a discussion on this topic, since immutable datastructures is a love of mine. @whyrusleeping could you elaborate?

whyrusleeping commented 9 years ago

My idea is that we control the creation of the merkledag.Node type. and prevent it from being created by a user, then we introduce a type called merkledag.MutableNode (or something less java-ey) that is used for constructing and modifying dags. Doing this will more closely follow the semantics of 'immutable dags' that ipfs really pushes.

jbenet commented 9 years ago

I think:

merkledag.Node  // immutable
merkledag.MutableNode

:+1: is a good idea.

(MutableNode is only two words-- not too unidiomatic. if we end up with anything that matches MutableNode(Factory|Abstract)+ though...)

whyrusleeping commented 9 years ago

merkledag.MutableMerkledagNodeFactoryBuilderImpl.GetFactoryBuilderInstance()

whyrusleeping commented 8 years ago

closing this for now... things will change with ipld.