Documentation ¶
Overview ¶
Holographic storage for distributed applications. A holochain is a monotonic distributed hash table (DHT) where every node enforces validation rules on data before publishing that data against the signed chains where the data originated.
In other words, a holochain functions very much like a blockchain without bottlenecks when it comes to enforcing validation rules, but is designed to be fully distributed with each node only needing to hold a small portion of the data instead of everything needing a full copy of a global ledger. This makes it feasible to run blockchain-like applications on devices as lightweight as mobile phones.
Two Subsystems ¶
There are two modes to participate in a holochain: as a **chain author**, and as a **DHT node**. We expect most installations will be doing both things and acting as full peers in a P2P data system. However, each could be run in a separate container, communicating only by network interface.
Authoring your Local Chain ¶
Your chain is your signed, sequential record of the data you create to share on the holochain. Depending on the holochain's validation rules, this data may also be immutable and non-repudiable. Your local chain/data-store follows this pattern:
- Validates your new data
- Stores the data in a new chain entry
- Signs it to your chain
- Indexes the content
- Shares it to the DHT
- Responds to validation requests from DHT nodes
DHT Node -- Validating and Publishing ¶
For serving data shared across the network. When your node receives a request from another node to publish DHT data, it will first validate the signatures, chain links, and any other application specific data integrity in the entity's source chain who is publishing the data.
Installation and Usage ¶
See http://github.com/metacurrency/holochain for installation instructions, project status, and developer information.
Holochains are a distributed data store: DHT tightly bound to signed hash chains for provenance and data integrity.
Index ¶
- Constants
- Variables
- func ByteDecoder(b []byte, to interface{}) (err error)
- func ByteEncoder(data interface{}) (b []byte, err error)
- func CopyDir(source string, dest string) (err error)
- func CopyFile(source string, dest string) (err error)
- func DHTReceiver(h *Holochain, m *Message) (response interface{}, err error)
- func Debug(m string)
- func Debugf(m string, args ...interface{})
- func Decode(reader io.Reader, format string, data interface{}) (err error)
- func Encode(writer io.Writer, format string, data interface{}) (err error)
- func Info(m string)
- func Infof(m string, args ...interface{})
- func IsInitialized(root string) bool
- func LoadTestData(path string) (map[string][]TestData, error)
- func MarshalEntry(writer io.Writer, e Entry) (err error)
- func MarshalHeader(writer io.Writer, hd *Header) (err error)
- func MarshalSignature(writer io.Writer, s *Signature) (err error)
- func Panix(on string)
- func Register()
- func RegisterBultinNucleii()
- func RegisterBultinPersisters()
- func RegisterNucleus(name string, factory NucleusFactory)
- func RegisterPersister(name string, factory PersisterFactory)
- func SaveAgent(path string, agent Agent) (err error)
- func ShouldLog(log *Logger, message string, fn func())
- func SrcReceiver(h *Holochain, m *Message) (response interface{}, err error)
- func ToString(input interface{}) string
- func UnmarshalHeader(reader io.Reader, hd *Header, hashSize int) (err error)
- func UnmarshalSignature(reader io.Reader, s *Signature) (err error)
- type Agent
- type AgentName
- type BSReq
- type BSResp
- type BoltPersister
- func (bp *BoltPersister) Close()
- func (bp *BoltPersister) DB() *bolt.DB
- func (bp *BoltPersister) Get(hash Hash, getEntry bool) (header Header, entry interface{}, e error)
- func (bp *BoltPersister) GetEntry(hash Hash) (entry interface{}, err error)
- func (bp *BoltPersister) GetMeta(key string) (data []byte, err error)
- func (bp *BoltPersister) Init() (err error)
- func (bp *BoltPersister) Name() string
- func (bp *BoltPersister) Open() (err error)
- func (bp *BoltPersister) Put(entryType string, headerHash Hash, header []byte, entryHash Hash, entry []byte) (err error)
- func (bp *BoltPersister) PutMeta(key string, value []byte) (err error)
- func (bp *BoltPersister) Remove() (err error)
- type Chain
- func (c *Chain) AddEntry(h HashSpec, now time.Time, entryType string, e Entry, key ic.PrivKey) (hash Hash, err error)
- func (c *Chain) Get(h Hash) (header *Header, err error)
- func (c *Chain) GetEntry(h Hash) (entry Entry, entryType string, err error)
- func (c *Chain) GetEntryHeader(h Hash) (header *Header, err error)
- func (c *Chain) MarshalChain(writer io.Writer) (err error)
- func (c *Chain) PrepareHeader(h HashSpec, now time.Time, entryType string, e Entry, key ic.PrivKey) (entryIdx int, hash Hash, header *Header, err error)
- func (c *Chain) String() string
- func (c *Chain) Top() (header *Header)
- func (c *Chain) TopType(entryType string) (hash *Hash, header *Header)
- func (c *Chain) Validate(h HashSpec) (err error)
- func (c *Chain) Walk(fn WalkerFn) (err error)
- type Change
- type ChangeType
- type Config
- type DHT
- func (dht *DHT) FindGossiper() (g *Gossiper, err error)
- func (dht *DHT) FindNodeForHash(key Hash) (n *Node, err error)
- func (dht *DHT) GetGossiper(id peer.ID) (idx int, err error)
- func (dht *DHT) GetIdx() (idx int, err error)
- func (dht *DHT) GetPuts(since int) (puts []Put, err error)
- func (dht *DHT) Gossip(interval time.Duration)
- func (dht *DHT) HandlePutReqs() (err error)
- func (dht *DHT) SendGet(key Hash) (response interface{}, err error)
- func (dht *DHT) SendGetMeta(query MetaQuery) (response interface{}, err error)
- func (dht *DHT) SendPut(key Hash) (err error)
- func (dht *DHT) SendPutMeta(req MetaReq) (err error)
- func (dht *DHT) SetupDHT() (err error)
- func (dht *DHT) StartDHT() (err error)
- func (dht *DHT) UpdateGossiper(id peer.ID, count int) (err error)
- type Entry
- type EntryDef
- type GetReq
- type GobEntry
- type Gossip
- type GossipReq
- type Gossiper
- type Hash
- func (h *Hash) Clone() (hash Hash)
- func (h1 *Hash) Equal(h2 *Hash) bool
- func (h *Hash) IsNullHash() bool
- func (h *Hash) MarshalHash(writer io.Writer) (err error)
- func (h Hash) String() string
- func (h *Hash) Sum(hc HashSpec, data []byte) (err error)
- func (h *Hash) UnmarshalHash(reader io.Reader) (err error)
- type HashSpec
- type Header
- type Holochain
- func (h *Holochain) Activate() (err error)
- func (h *Holochain) Agent() Agent
- func (h *Holochain) BSget() (err error)
- func (h *Holochain) BSpost() (err error)
- func (h *Holochain) Call(zomeType string, function string, arguments interface{}) (result interface{}, err error)
- func (h *Holochain) DHT() *DHT
- func (h *Holochain) DNAhash() (id Hash)
- func (h *Holochain) EncodeDNA(writer io.Writer) (err error)
- func (h *Holochain) GenChain() (keyHash Hash, err error)
- func (h *Holochain) GenDNAHashes() (err error)
- func (h *Holochain) GetEntryDef(t string) (zome *Zome, d *EntryDef, err error)
- func (h *Holochain) GetProperty(prop string) (property string, err error)
- func (h *Holochain) HashSpec() HashSpec
- func (h *Holochain) MakeNucleus(t string) (n Nucleus, err error)
- func (h *Holochain) NewEntry(now time.Time, entryType string, entry Entry) (hash Hash, header *Header, err error)
- func (h *Holochain) Path() string
- func (h *Holochain) Prepare() (err error)
- func (h *Holochain) PrepareHashType() (err error)
- func (h *Holochain) Reset() (err error)
- func (h *Holochain) SaveDNA(overwrite bool) (err error)
- func (h *Holochain) Send(proto protocol.ID, to peer.ID, t MsgType, body interface{}, ...) (response interface{}, err error)
- func (h *Holochain) Started() bool
- func (h *Holochain) Test() []error
- func (h *Holochain) TestStringReplacements(input, r1, r2, r3 string) string
- func (h *Holochain) Top() (top Hash, err error)
- func (h *Holochain) Validate(entriesToo bool) (valid bool, err error)
- func (h *Holochain) ValidateEntry(entryType string, entry Entry, props *ValidationProps) (err error)
- func (h *Holochain) Walk(fn WalkerFn, entriesToo bool) (err error)
- type HolochainRouter
- type IPFSAgent
- type Interface
- type InterfaceSchemaType
- type JSNucleus
- func (z *JSNucleus) Call(iface string, params interface{}) (result interface{}, err error)
- func (z *JSNucleus) ChainGenesis() (err error)
- func (z *JSNucleus) ChainRequires() (err error)
- func (z *JSNucleus) GetInterface(iface string) (i *Interface, err error)
- func (z *JSNucleus) Interfaces() (i []Interface)
- func (z *JSNucleus) Run(code string) (result *otto.Value, err error)
- func (z *JSNucleus) Type() string
- func (z *JSNucleus) ValidateEntry(d *EntryDef, entry Entry, props *ValidationProps) (err error)
- type JSONEntry
- type JSONSchemaValidator
- type KeyEntry
- type KeytypeType
- type Logger
- type Loggers
- type Message
- type Meta
- type MetaEntry
- type MetaQuery
- type MetaQueryResp
- type MetaReq
- type MsgType
- type Node
- func (node *Node) Close() error
- func (node *Node) NewMessage(t MsgType, body interface{}) (msg *Message)
- func (node *Node) Send(proto protocol.ID, addr peer.ID, m *Message) (response Message, err error)
- func (node *Node) StartProtocol(h *Holochain, proto protocol.ID, receiver ReceiverFn) (err error)
- func (node *Node) StartSrc(h *Holochain) (err error)
- type Nucleus
- type NucleusFactory
- type Persister
- type PersisterFactory
- type Put
- type PutReq
- type ReceiverFn
- type SchemaValidator
- type Service
- func (s *Service) Clone(srcPath string, path string, new bool) (hP *Holochain, err error)
- func (s *Service) ConfiguredChains() (chains map[string]*Holochain, err error)
- func (s *Service) GenDev(path string, format string) (hP *Holochain, err error)
- func (s *Service) IsConfigured(name string) (f string, err error)
- func (s *Service) Load(name string) (h *Holochain, err error)
- type ServiceConfig
- type Signature
- type TestData
- type ValidateResponse
- type ValidationProps
- type WalkerFn
- type Zome
- type ZygoNucleus
- func (z *ZygoNucleus) Call(iface string, params interface{}) (result interface{}, err error)
- func (z *ZygoNucleus) ChainGenesis() (err error)
- func (z *ZygoNucleus) ChainRequires() (err error)
- func (z *ZygoNucleus) GetInterface(iface string) (i *Interface, err error)
- func (z *ZygoNucleus) Interfaces() (i []Interface)
- func (z *ZygoNucleus) Run(code string) (result zygo.Sexp, err error)
- func (z *ZygoNucleus) Type() string
- func (z *ZygoNucleus) ValidateEntry(d *EntryDef, entry Entry, props *ValidationProps) (err error)
Constants ¶
const ( SampleHTML = `` /* 678-byte string literal not displayed */ SampleJS = `` /* 440-byte string literal not displayed */ )
const ( PutNew = iota PutUpdate PutDelete PutUndelete )
const ( LIVE = iota REJECTED DELETED UPDATED )
const ( DNAEntryType = "_dna" KeyEntryType = "_key" )
const ( DataFormatJSON = "json" DataFormatString = "string" DataFormatRawJS = "js" DataFormatRawZygo = "zygo" )
const ( DHTProtocol = protocol.ID("/holochain-dht/0.0.0") SourceProtocol = protocol.ID("/holochain-src/0.0.0") )
const ( ID_PROPERTY = "_id" AGENT_ID_PROPERTY = "_agent_id" AGENT_NAME_PROPERTY = "_agent_name" )
const ( IDMetaKey = "id" TopMetaKey = "top" MetaBucket = "M" HeaderBucket = "H" EntryBucket = "E" )
const ( DefaultDirectoryName string = ".holochain" // Directory for storing config data DNAFileName string = "dna" // Definition of the Holochain ConfigFileName string = "config" // Settings of the Holochain SysFileName string = "system.conf" // Server & System settings AgentFileName string = "agent.txt" // User ID info PrivKeyFileName string = "priv.key" // Signing key - private StoreFileName string = "chain" // Filename for local data store DNAHashFileName string = "dna.hash" // Filename for storing the hash of the holochain DefaultPort = 6283 )
System settings, directory, and file names
const (
BoltPersisterName = "bolt"
)
const (
IPFS = iota
)
const (
JSLibrary = `var HC={STRING:0,JSON:1};version=` + `"` + VersionStr + `";`
)
const (
JSNucleusType = "js"
)
const Version int = 2
const VersionStr string = "2"
const (
ZygoLibrary = `(def STRING 0) (def JSON 1)`
)
These are the zygo implementations of the library functions that must available in all Nucleii implementations.
const (
ZygoNucleusType = "zygo"
)
Variables ¶
var ChangeAppProperty = Change{ Type: Deprecation, Message: "Getting special properties via property() is deprecated as of %d", AsOf: 2, }
var ChangeRequires = Change{ Type: Warning, Message: "Zomes must define 'requires' function as of version %d, assuming no requirements.", AsOf: 2, }
var Crash bool
var DEBUG bool
var ErrDHTErrNoGossipersAvailable error = errors.New("no gossipers available")
var ErrDHTExpectedGetReqInBody error = errors.New("expected get request")
var ErrDHTExpectedGossipReqInBody error = errors.New("expected gossip request")
var ErrDHTExpectedMetaQueryInBody error = errors.New("expected meta query")
var ErrDHTExpectedMetaReqInBody error = errors.New("expected meta request")
var ErrDHTExpectedPutReqInBody error = errors.New("expected put request")
var ErrHashNotFound error = errors.New("hash not found")
var SampleUI = map[string]string{ "index.html": SampleHTML, "hc.js": SampleJS, }
Functions ¶
func ByteDecoder ¶
ByteEncoder decodes data encoded by ByteEncoder
func ByteEncoder ¶
ByteEncoder encodes anything using gob
func CopyDir ¶
CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist.
func DHTReceiver ¶
DHTReceiver handles messages on the dht protocol
func IsInitialized ¶
IsInitialized checks a path for a correctly set up .holochain directory
func MarshalEntry ¶
MarshalEntry serializes an entry to a writer
func MarshalHeader ¶
MarshalHeader writes a header to a binary stream
func MarshalSignature ¶
MarshalSignature writes a signature to a binary stream
func Register ¶
func Register()
Register function that must be called once at startup by any client app
func RegisterBultinNucleii ¶
func RegisterBultinNucleii()
RegisterBultinNucleii adds the built in nucleus types to the factory hash
func RegisterBultinPersisters ¶
func RegisterBultinPersisters()
RegisterBultinPersisters adds the built in persister types to the factory hash
func RegisterNucleus ¶
func RegisterNucleus(name string, factory NucleusFactory)
RegisterNucleus sets up a Nucleus to be used by the CreateNucleus function
func RegisterPersister ¶
func RegisterPersister(name string, factory PersisterFactory)
RegisterPersister sets up a Persister to be used by the CreatePersister function
func SrcReceiver ¶
SrcReceiver handles messages on the Source protocol
func UnmarshalHeader ¶
UnmarshalHeader reads a Header from a binary stream
Types ¶
type Agent ¶
type Agent interface { Name() AgentName KeyType() KeytypeType GenKeys() error PrivKey() ic.PrivKey PubKey() ic.PubKey }
type BoltPersister ¶
type BoltPersister struct {
// contains filtered or unexported fields
}
func (*BoltPersister) DB ¶
func (bp *BoltPersister) DB() *bolt.DB
DB returns the bolt db to give clients direct accesses to the bolt store
func (*BoltPersister) Get ¶
func (bp *BoltPersister) Get(hash Hash, getEntry bool) (header Header, entry interface{}, e error)
Get returns a header, and (optionally) it's entry if getEntry is true
func (*BoltPersister) GetEntry ¶
func (bp *BoltPersister) GetEntry(hash Hash) (entry interface{}, err error)
func (*BoltPersister) GetMeta ¶
func (bp *BoltPersister) GetMeta(key string) (data []byte, err error)
GetMeta returns meta data
func (*BoltPersister) Init ¶
func (bp *BoltPersister) Init() (err error)
Init opens the store (if it isn't already open) and initializes buckets
func (*BoltPersister) Name ¶
func (bp *BoltPersister) Name() string
Name returns the data store name
func (*BoltPersister) Put ¶
func (bp *BoltPersister) Put(entryType string, headerHash Hash, header []byte, entryHash Hash, entry []byte) (err error)
Put stores an entry and its header N.B. this function does not confirm that the hashes match the values. That must be done external to the persister!
func (*BoltPersister) PutMeta ¶
func (bp *BoltPersister) PutMeta(key string, value []byte) (err error)
PutMeta sets meta data
func (*BoltPersister) Remove ¶
func (bp *BoltPersister) Remove() (err error)
Remove deletes all data in the datastore
type Chain ¶
type Chain struct { Hashes []Hash Headers []*Header Entries []Entry TypeTops map[string]int // pointer to index of top of a given type Hmap map[string]int // map header hashes to index number Emap map[string]int // map entry hashes to index number // contains filtered or unexported fields }
Chain structure for providing in-memory access to chain data, entries headers and hashes
func NewChainFromFile ¶
Creates a chain from a file, loading any data there, and setting it to be persisted to if no file exists it will be created
func UnmarshalChain ¶
UnmarshalChain unserializes a chain from a reader
func (*Chain) AddEntry ¶
func (c *Chain) AddEntry(h HashSpec, now time.Time, entryType string, e Entry, key ic.PrivKey) (hash Hash, err error)
AddEntry creates a new header and adds it to a chain
func (*Chain) GetEntryHeader ¶
GetEntryHeader returns the header of a given entry hash
func (*Chain) MarshalChain ¶
MarshalChain serializes a chain data to a writer
func (*Chain) PrepareHeader ¶
type Change ¶
type Change struct { Type ChangeType Message string AsOf int }
Change represents a semantic change that needs to be reported
type Config ¶
type Config struct { Port int PeerModeAuthor bool PeerModeDHTNode bool BootstrapServer string Loggers Loggers }
Config holds the non-DNA configuration for a holo-chain
type DHT ¶
type DHT struct {
// contains filtered or unexported fields
}
DHT struct holds the data necessary to run the distributed hash table
func (*DHT) FindGossiper ¶
FindGossiper picks a random DHT node to gossip with
func (*DHT) FindNodeForHash ¶
FindNodeForHash gets the nearest node to the neighborhood of the hash
func (*DHT) GetGossiper ¶
GetGossiper picks a random DHT node to gossip with
func (*DHT) HandlePutReqs ¶
HandlePutReqs waits on a chanel for messages to handle
func (*DHT) SendGetMeta ¶
SendGetMeta initiates retrieving meta data from the DHT
func (*DHT) SendPut ¶
SendPut initiates publishing a particular Hash to the DHT. This command only sends the hash, because the expectation is that DHT nodes will start to communicate back to Source node (the node that makes this call) to get the data for validation
func (*DHT) SendPutMeta ¶
SendPutMeta initiates associating Meta data with particular Hash on the DHT. This command assumes that the data has been committed to your local chain, and the hash of that data is what get's sent in the MetaReq
type Entry ¶
type Entry interface { Marshal() ([]byte, error) Unmarshal([]byte) error Content() interface{} Sum(s HashSpec) (hash Hash, err error) }
Entry describes serialization and deserialziation of entry data
type EntryDef ¶
type EntryDef struct { Name string DataFormat string Schema string // file name of schema or language schema directive SchemaHash Hash // contains filtered or unexported fields }
EntryDef struct holds an entry definition
func (*EntryDef) BuildJSONSchemaValidator ¶
BuildJSONSchemaValidator builds a validator in an EntryDef
type GobEntry ¶
type GobEntry struct {
C interface{}
}
GobEntry is a structure for implementing Gob encoding of Entry content
type Hash ¶
Hash of Entry's Content
func (*Hash) IsNullHash ¶
IsNullHash checks to see if this hash's value is the null hash
func (*Hash) MarshalHash ¶
MarshalHash writes a hash to a binary stream
type Header ¶
type Header struct { Type string Time time.Time HeaderLink Hash // link to previous header EntryLink Hash // link to entry TypeLink Hash // link to header of previous header of this type Sig Signature }
Header holds chain links, type, timestamp and signature
type Holochain ¶
type Holochain struct { Version int Id uuid.UUID Name string Properties map[string]string PropertiesSchema string HashType string BasedOn Hash // holochain hash for base schemas and code Zomes map[string]*Zome // contains filtered or unexported fields }
Holochain struct holds the full "DNA" of the holochain
func NewHolochain ¶
NewHolochain creates a new holochain structure with a randomly generated ID and default values
func (*Holochain) Call ¶
func (h *Holochain) Call(zomeType string, function string, arguments interface{}) (result interface{}, err error)
Call executes an exposed function
func (*Holochain) DNAhash ¶
DNAhash returns the hash of the DNA entry which is also the holochain ID
func (*Holochain) GenChain ¶
GenChain establishes a holochain instance by creating the initial genesis entries in the chain It assumes a properly set up .holochain sub-directory with a config file and keys for signing. See GenDev()
func (*Holochain) GenDNAHashes ¶
GenDNAHashes generates hashes for all the definition files in the DNA. This function should only be called by developer tools at the end of the process of finalizing DNA development or versioning
func (*Holochain) GetEntryDef ¶
GetEntryDef returns an EntryDef of the given name
func (*Holochain) GetProperty ¶
GetProperty returns the value of a DNA property
func (*Holochain) MakeNucleus ¶
MakeNucleus creates a Nucleus object based on the zome type
func (*Holochain) NewEntry ¶
func (h *Holochain) NewEntry(now time.Time, entryType string, entry Entry) (hash Hash, header *Header, err error)
NewEntry adds an entry and it's header to the chain and returns the header and it's hash
func (*Holochain) Prepare ¶
Prepare sets up a holochain to run by: validating the DNA, loading the schema validators, setting up a Network node and setting up the DHT
func (*Holochain) PrepareHashType ¶
PrepareHashType makes sure the given string is a correct multi-hash and stores the code and length to the Holochain struct
func (*Holochain) Send ¶
func (h *Holochain) Send(proto protocol.ID, to peer.ID, t MsgType, body interface{}, receiver ReceiverFn) (response interface{}, err error)
Send builds a message and either delivers it locally or via node.Send
func (*Holochain) Test ¶
Test loops through each of the test files calling the functions specified This function is useful only in the context of developing a holochain and will return an error if the chain has already been started (i.e. has genesis entries)
func (*Holochain) TestStringReplacements ¶
func (*Holochain) Validate ¶
Validate scans back through a chain to the beginning confirming that the last header points to DNA This is actually kind of bogus on your own chain, because theoretically you put it there! But if the holochain file was copied from somewhere you can consider this a self-check
func (*Holochain) ValidateEntry ¶
func (h *Holochain) ValidateEntry(entryType string, entry Entry, props *ValidationProps) (err error)
ValidateEntry passes an entry data to the chain's validation routine If the entry is valid err will be nil, otherwise it will contain some information about why the validation failed (or, possibly, some other system error)
type HolochainRouter ¶
type HolochainRouter struct {
// contains filtered or unexported fields
}
type IPFSAgent ¶
type IPFSAgent struct {
// contains filtered or unexported fields
}
func (*IPFSAgent) KeyType ¶
func (a *IPFSAgent) KeyType() KeytypeType
type Interface ¶
type Interface struct { Name string Schema InterfaceSchemaType }
Interface holds the name and schema of an DNA exposed function
type InterfaceSchemaType ¶
type InterfaceSchemaType int
const ( STRING InterfaceSchemaType = iota JSON )
func InterfaceSchema ¶
func InterfaceSchema(n Nucleus, name string) (InterfaceSchemaType, error)
InterfaceSchema returns a functions schema type
type JSNucleus ¶
type JSNucleus struct {
// contains filtered or unexported fields
}
func (*JSNucleus) ChainGenesis ¶
ChainGenesis runs the application genesis function this function gets called after the genesis entries are added to the chain
func (*JSNucleus) ChainRequires ¶
ChainReqires runs the application requires function this function gets called so that the holochain library can confirm that it is capable of servicing the needs of the application.
func (*JSNucleus) GetInterface ¶
GetInterface returns an Interface of the given name
func (*JSNucleus) Interfaces ¶
Interfaces returns the list of application exposed functions the nucleus
func (*JSNucleus) ValidateEntry ¶
func (z *JSNucleus) ValidateEntry(d *EntryDef, entry Entry, props *ValidationProps) (err error)
ValidateEntry checks the contents of an entry against the validation rules this is the zgo implementation
type JSONEntry ¶
type JSONEntry struct {
C interface{}
}
JSONEntry is a structure for implementing JSON encoding of Entry content
type JSONSchemaValidator ¶
type JSONSchemaValidator struct {
// contains filtered or unexported fields
}
func (*JSONSchemaValidator) Validate ¶
func (v *JSONSchemaValidator) Validate(entry interface{}) (err error)
type KeyEntry ¶
type KeyEntry struct { Name AgentName KeyType KeytypeType Key []byte // marshaled public key }
KeyEntry structure for building KeyEntryType entries
type KeytypeType ¶
type KeytypeType int
type Loggers ¶
type Loggers struct { App Logger DHT Logger Gossip Logger TestPassed Logger TestFailed Logger TestInfo Logger }
Loggers holds the logging structures for the different parts of the system
type Message ¶
Message represents data that can be sent to node in the network
type Meta ¶
type Meta struct { H Hash // hash of meta-data associated T string // meta-data type identifier V []byte // meta-data }
Meta holds data that can be associated with a hash @todo, we should also be storing the meta-data source
type MetaQueryResp ¶
type MetaQueryResp struct {
Entries []MetaEntry
}
MetaQueryResp holds response to getMeta query
type MetaReq ¶
type MetaReq struct { O Hash // original data on which to put the meta M Hash // hash of the meta-data T string // type of the meta-data }
MetaReq holds a putMeta request
type Node ¶
Node represents a node in the network
func (*Node) NewMessage ¶
NewMessage creates a message from the node with a new current timestamp
func (*Node) StartProtocol ¶
StartProtocol initiates listening for a protocol on the node
type Nucleus ¶
type Nucleus interface { Type() string ValidateEntry(def *EntryDef, entry Entry, props *ValidationProps) error ChainGenesis() error ChainRequires() error Interfaces() (i []Interface) Call(iface string, params interface{}) (interface{}, error) // contains filtered or unexported methods }
Nucleus type abstracts the functions of code execution environments
func CreateNucleus ¶
CreateNucleus returns a new Nucleus of the given type
func NewJSNucleus ¶
NewJSNucleus builds a javascript execution environment with user specified code
type Persister ¶
type Persister interface { Open() error Close() Init() error GetMeta(string) ([]byte, error) PutMeta(key string, value []byte) (err error) Put(entryType string, headerHash Hash, header []byte, entryHash Hash, entry []byte) (err error) Get(hash Hash, getEntry bool) (header Header, entry interface{}, err error) GetEntry(hash Hash) (entry interface{}, err error) Remove() error Name() string }
func CreatePersister ¶
CreatePersister returns a new Persister of the given type
func NewBoltPersister ¶
NewBoltPersister returns a Bolt implementation of the Persister type always return no error because in this case any errors would happen at Init or Open time
type PersisterFactory ¶
type ReceiverFn ¶
type SchemaValidator ¶
type SchemaValidator interface {
Validate(interface{}) error
}
SchemaValidator interface for schema validation
type Service ¶
type Service struct { Settings ServiceConfig DefaultAgent Agent Path string }
Holochain service data structure
func Init ¶
Init initializes service defaults including a signing key pair for an agent and writes them out to configuration files in the root path (making the directory if necessary)
func LoadService ¶
LoadService creates a service object from a configuration file
func (*Service) ConfiguredChains ¶
ConfiguredChains returns a list of the configured chains for the given service
func (*Service) IsConfigured ¶
IsConfigured checks a directory for correctly set up holochain configuration files
type ServiceConfig ¶
type ServiceConfig struct { DefaultPeerModeAuthor bool DefaultPeerModeDHTNode bool DefaultBootstrapServer string }
ServiceConfig holds the service settings
type TestData ¶
type TestData struct { Zome string FnName string Input string Output string Err string Regexp string }
TestData holds a test entry for a chain
type ValidateResponse ¶
type ValidationProps ¶
type ValidationProps struct { Sources []string // B58 encoded peer Hash string MetaTag string // if validating a putMeta this will have the meta type set MetaHash string }
ValidationProps holds the properties passed to the application validation routine This includes the Headers and Sources
type Zome ¶
type Zome struct { Name string Description string Code string // file name of DNA code CodeHash Hash Entries map[string]EntryDef NucleusType string }
Zome struct encapsulates logically related code, from "chromosome"
type ZygoNucleus ¶
type ZygoNucleus struct {
// contains filtered or unexported fields
}
func (*ZygoNucleus) Call ¶
func (z *ZygoNucleus) Call(iface string, params interface{}) (result interface{}, err error)
Call calls the zygo function that was registered with expose
func (*ZygoNucleus) ChainGenesis ¶
func (z *ZygoNucleus) ChainGenesis() (err error)
ChainGenesis runs the application genesis function this function gets called after the genesis entries are added to the chain
func (*ZygoNucleus) ChainRequires ¶
func (z *ZygoNucleus) ChainRequires() (err error)
ChainReqires runs the application requires function this function gets called so that the holochain library can confirm that it is capable of servicing the needs of the application.
func (*ZygoNucleus) GetInterface ¶
func (z *ZygoNucleus) GetInterface(iface string) (i *Interface, err error)
GetInterface returns an Interface of the given name
func (*ZygoNucleus) Interfaces ¶
func (z *ZygoNucleus) Interfaces() (i []Interface)
Interfaces returns the list of application exposed functions the nucleus
func (*ZygoNucleus) Run ¶
func (z *ZygoNucleus) Run(code string) (result zygo.Sexp, err error)
Run executes zygo code
func (*ZygoNucleus) Type ¶
func (z *ZygoNucleus) Type() string
Name returns the string value under which this nucleus is registered
func (*ZygoNucleus) ValidateEntry ¶
func (z *ZygoNucleus) ValidateEntry(d *EntryDef, entry Entry, props *ValidationProps) (err error)
ValidateEntry checks the contents of an entry against the validation rules