@cryptotaxi247 / kubo / commits / d8bc95f43

invalidate merkledag cache when modifying children

Jeromy committed Mar 19, 2015 at 22:50 UTC d8bc95f43ea0452566070e848cba4ffaccea50c3
1 file changed +3
merkledag/node.go
+3
@@ -87,6 +87,7 @@ func (l *Link) GetNode(serv DAGService) (*Node, error) {
87
88 // AddNodeLink adds a link to another node.
89 func (n *Node) AddNodeLink(name string, that *Node) error {
90 + n.encoded = nil
91 lnk, err := MakeLink(that)
92 if err != nil {
93 return err
@@ -101,6 +102,7 @@ func (n *Node) AddNodeLink(name string, that *Node) error {
102 // AddNodeLink adds a link to another node. without keeping a reference to
103 // the child node
104 func (n *Node) AddNodeLinkClean(name string, that *Node) error {
105 + n.encoded = nil
106 lnk, err := MakeLink(that)
107 if err != nil {
108 return err
@@ -113,6 +115,7 @@ func (n *Node) AddNodeLinkClean(name string, that *Node) error {
115
116 // Remove a link on this node by the given name
117 func (n *Node) RemoveNodeLink(name string) error {
118 + n.encoded = nil
119 for i, l := range n.Links {
120 if l.Name == name {
121 n.Links = append(n.Links[:i], n.Links[i+1:]...)