base - SkycoinWikis/CXO GitHub Wiki

CXO HOME » CX » CXO » BASE

Base

If there is some data you want to share and to update it time-to-time. And if you want to replicate the data using many machines (servers and peers), then CXO is for you. But CXO based on blockchain and there are not some data types (like hash-tables).

Table of Contents

Owner and feed

Owner is someone who want to share something. Owner described by secret key. And related public key is feed shared by the Owner. So. A man can share many feeds, and every feed described by public key with related secret key.

What is public key and secret key in code?
import (
    "github.com/skycoin/skycoin/src/cipher"
)

// [...]

func someFunc() {
    var feed, owner = cipher.GenerateKeyPair() // random
    // stuff
}
Docs
Signature

And while an Owner share some data, he sign the data using his secret key. And everyone who receive the data can check the signature and be sure that the data comes from the Owner (the recipient knows the public key, because a feed is a public key).

How a feed looks like

A feed based on Root objects. A Root keeps references to objects to share. And this objects can be any. And this objects can keep references to another objects, etc, etc. But the Root is root of the objects tree. And a CXO node send Root object to subscribers, then the subscribers request related objects to get entire tree. If owner wants to update his feed, then the owner update the Root. E.g. he creates new version of feed - new Root.

cxo sharing

CXO never cares about "old" Root objects replicating only latest Root of a feed. And end-user (developer, an application over CXO) should care about updating speed. If an owner generate Root objects very often, then all related CXO nodes those replicate his feed can allocate many resources. Best way is: update after most related nodes finish replicating previous Root object. This way every related node will keep all previous Root objects (history) and application have to remove them by needs to release space. Fox example, keeping only 100 latest Root objects. Or keeping only latest one.

Schema and data

An average Root points to shared objects (also, it can be empty). To be able to decode this object and traverse objects tree, these closest to Root objects, has references to schema. And the Root points to registry of all possible schema of the tree. An object is a structure. And schema of an object keeps information about schema of a field (if field is type of reference). Thus, nested objects don't have references to schema, but schema of these objects do.

cxo sharing

A reference is hash that points to encoded object (hash of the encoded object, actually). If a reference points to many objects, then Merkle-tree used.

Subscribe and replicate

A CXO node have to subscribe to a feed to receive updates and get latest known Root objects (with all related objects, actually). Thus, a CXO node have to know: IP address of a node that replicates wanted feed, and the feed.

code example
        // n          - our CXO node
        // pk         - public key of wanted feed
        // [::1]:8087 - IP address of node that replicate the feed

	// connect

	var conn *node.Conn
	if conn, err = n.TCP().Connect("[::1]:8087"); err != nil {
		log.Fatal(err)
	}

	// subscribe

	if err = conn.Subscribe(pk); err != nil {
		log.Fatal(err)
	}
Discovery server

There is a way to join swarm of CXO nodes using discovery server that connects nodes between depending on interests.

Preview

There is a way to preview a feed without subscription. Just get latest Root of the feed.

⚠️ **GitHub.com Fallback** ⚠️