Пример #1
0
func (t *Thread) updateLink(n *merkledag.Node, stamp time.Time) func(bool, *merkledag.Node) (bool, error) {
	return func(exist bool, prev *merkledag.Node) (bool, error) {
		if exist {
			return false, nil
		}
		pren, err := getLinkName(prev)
		if log.If(err) {
			return false, err
		}
		if pren != nil {
			log.Println(pren.stamp)
			pn := pren.string()
			raw, errr := prev.GetNodeLink(pn)
			if log.If(errr) {
				return false, errr
			}
			if errr := n.AddRawLink(pn, raw); log.If(errr) {
				return false, errr
			}
			if errr := prev.RemoveNodeLink(pn); log.If(errr) {
				return false, errr
			}
		}
		name := &linkName{stamp: stamp}
		log.Println(name.stamp)

		if err := prev.AddNodeLink(name.string(), n); log.If(err) {
			return false, err
		}
		log.If(err)
		return true, err
	}
}