1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-22 04:09:04 +08:00

invalidate merkledag cache when modifying children

This commit is contained in:
Jeromy
2015-03-19 22:50:28 -07:00
parent 13de031b44
commit d8bc95f43e

View File

@ -87,6 +87,7 @@ func (l *Link) GetNode(serv DAGService) (*Node, error) {
// AddNodeLink adds a link to another node.
func (n *Node) AddNodeLink(name string, that *Node) error {
n.encoded = nil
lnk, err := MakeLink(that)
if err != nil {
return err
@ -101,6 +102,7 @@ func (n *Node) AddNodeLink(name string, that *Node) error {
// AddNodeLink adds a link to another node. without keeping a reference to
// the child node
func (n *Node) AddNodeLinkClean(name string, that *Node) error {
n.encoded = nil
lnk, err := MakeLink(that)
if err != nil {
return err
@ -113,6 +115,7 @@ func (n *Node) AddNodeLinkClean(name string, that *Node) error {
// Remove a link on this node by the given name
func (n *Node) RemoveNodeLink(name string) error {
n.encoded = nil
for i, l := range n.Links {
if l.Name == name {
n.Links = append(n.Links[:i], n.Links[i+1:]...)