Ejemplo n.º 1
0
func SendToPath(data []byte, path *big.Int) {
	// Every API client have is own simple number but with negative value for splitting path
	for n, c := range api_connections {
		if n.Int64() > 0 {
			if ok, _ := tree_lib.IsBigDividable(path, n); ok {
				SendToConn(data, c, path)
			}
		}
	}

	// First of all trying to send to parent
	if node_info.ParentNodeValue != nil && node_info.ParentNodeValue.Int64() > 0 {
		if ok, _ := tree_lib.IsBigDividable(path, node_info.ParentNodeValue); ok {
			SendToParent(data, path)
		}
	}

	for n, v := range node_info.ChildsNodeValue {
		if v != nil && v.Int64() > 0 {
			if ok, _ := tree_lib.IsBigDividable(path, v); ok {
				SendToChild(data, n, path)
			}
		}
	}
}
Ejemplo n.º 2
0
func handle_message(is_api, from_parent bool, msg []byte) (err tree_lib.TreeError) {
	var (
		msg_body []byte
		path     *big.Int
	)
	err.From = tree_lib.FROM_HANDLE_MESSAGE
	msg_body, path = tree_graph.PathValueFromMessage(msg)

	// If current node dividable to path, then it should execute this event
	if ok, _ := tree_lib.IsBigDividable(path, node_info.CurrentNodeValue); ok {
		go tree_event.TriggerFromData(msg_body)
	}

	SendToPath(msg_body, path)

	return
}