Documentation ¶
Overview ¶
Copyright (C) 2013-2018, The MetaCurrency Project (Eric Harris-Braun, Arthur Brock, et. al.) Use of this source code is governed by GPLv3 found in the LICENSE file ----------------------------------------------------------------------------------------
Copyright (C) 2013-2018, The MetaCurrency Project (Eric Harris-Braun, Arthur Brock, et. al.) Use of this source code is governed by GPLv3 found in the LICENSE file ----------------------------------------------------------------------------------------
Copyright (C) 2013-2018, The MetaCurrency Project (Eric Harris-Braun, Arthur Brock, et. al.) Use of this source code is governed by GPLv3 found in the LICENSE file ----------------------------------------------------------------------------------------
Copyright (C) 2013-2018, The MetaCurrency Project (Eric Harris-Braun, Arthur Brock, et. al.) Use of this source code is governed by GPLv3 found in the LICENSE file ----------------------------------------------------------------------------------------
package holochain should be imported by go packages intending to create a UI for this holochain implementation.
An example of a package which imports holochain is https://github.com/holochain/holochain-proto/tree/master/cmd/hc
For information not found here see the wiki:
https://github.com/holochain/holochain-proto/wiki
or the repo:
https://github.com/holochain/holochain-proto
If you are here because you intend to develop an application built on holochain take a look at the App Developer sections of the wiki.
If you would like a description of the architecture/technical aspects of holochain look at those sections of the wiki.
Data integrity engine for distributed applications -- a validating monotonic DHT "backed" by authoritative hashchains for data provenance.
Copyright (C) 2013-2017, The MetaCurrency Project (Eric Harris-Braun, Arthur Brock, et. al.) Use of this source code is governed by GPLv3 found in the LICENSE file ----------------------------------------------------------------------------------------
This code is adapted from the libp2p project, specifically: https://github.com/libp2p/go-libp2p-kad-dht/notif.go
The ipfs use of kademlia is substantially different than that needed by holochain so we remove parts we don't need and add others.
Index ¶
- Constants
- Variables
- func ActionReceiver(h *Holochain, msg *Message) (response interface{}, err error)
- func BootstrapRefreshTask(h *Holochain)
- func ByteDecoder(b []byte, to interface{}) (err error)
- func ByteEncoder(data interface{}) (b []byte, err error)
- func CleanupTestChain(h *Holochain, d string)
- func CleanupTestDir(path string)
- func CopyDir(source string, dest string) (err error)
- func CopyFile(source string, dest string) (err error)
- func DNAHashofUngenedChain(h *Holochain) (DNAHash Hash, err error)
- func Debug(m string)
- func Debugf(m string, args ...interface{})
- func DebuggingRequestedViaEnv() (val, yes bool)
- func Decode(reader io.Reader, format string, data interface{}) (err error)
- func DecodeFile(data interface{}, pathParts ...string) (err error)
- func DecodePubKey(b58pk string) (pubKey ic.PubKey, err error)
- func DirExists(pathParts ...string) bool
- func Encode(writer io.Writer, format string, data interface{}) (err error)
- func EncodingFormat(file string) (f string)
- func EscapeJSONValue(json string) string
- func FileExists(pathParts ...string) bool
- func FileSize(pathParts ...string) int64
- func GetAllTestRoles(path string) (roleNameList []string, err error)
- func GetTestScenarioRoles(h *Holochain, scenarioName string) (roleNameList []string, err error)
- func GetTestScenarios(h *Holochain) (scenarios map[string]*os.FileInfo, err error)
- func GossipReceiver(h *Holochain, m *Message) (response interface{}, err error)
- func GossipTask(h *Holochain)
- func HoldingTask(h *Holochain)
- func Info(m string)
- func Infof(m string, args ...interface{})
- func InitializeHolochain()
- func IsInitialized(root string) bool
- func IsValidationFailedErr(err error) bool
- func KademliaReceiver(h *Holochain, m *Message) (response interface{}, err error)
- func LoadTestFiles(path string) (map[string]TestSet, error)
- func MakeDirs(devPath string) error
- func MakeReceiptData(msg *Message, code int) (reciept []byte, err error)
- func MakeTestDirName() string
- func MakeTestSeed(id string) io.Reader
- 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 NormaliseJSON(json string) string
- func Panix(on string)
- func PrepareTestChain(n string) (d string, s *Service, h *Holochain)
- func PrettyPrintJSON(b []byte) (string, error)
- func ReadFile(pathParts ...string) (data []byte, err error)
- func RegisterBultinRibosomes()
- func RegisterRibosome(name string, factory RibosomeFactory)
- func RetryTask(h *Holochain)
- func RoutingRefreshTask(h *Holochain)
- func RunValidationPhase(h *Holochain, source peer.ID, msgType MsgType, query Hash, ...) (err error)
- func SaveAgent(path string, agent Agent) (err error)
- func SetAgentIdentity(agent Agent, identity AgentIdentity)
- func SetIdentity(h *Holochain, identity AgentIdentity)
- func SetupTestChain(n string) (d string, s *Service, h *Holochain)
- func SetupTestDir() string
- func ShouldLog(log *Logger, fn func(), messages ...string)
- func SortClosestPeers(peers []peer.ID, target Hash) []peer.ID
- func TestingAppAppPackage() string
- func Ticker(interval time.Duration, fn func()) (stopper chan bool)
- func UnmarshalHeader(reader io.Reader, hd *Header, hashSize int) (err error)
- func UnmarshalSignature(reader io.Reader, s *Signature) (err error)
- func ValidateReceiver(h *Holochain, msg *Message) (response interface{}, err error)
- func ValidationFailed(msgs ...string) error
- func WriteFile(data []byte, pathParts ...string) error
- type APIFnBridge
- type APIFnCall
- type APIFnCloseBundle
- type APIFnCommit
- type APIFnDebug
- type APIFnDel
- type APIFnGet
- type APIFnGetBridges
- type APIFnGetLinks
- type APIFnMakeHash
- type APIFnMigrate
- type APIFnMod
- type APIFnModAgent
- type APIFnProperty
- type APIFnQuery
- type APIFnSend
- type APIFnSign
- type APIFnStartBundle
- type APIFnVerifySignature
- type APIFunction
- type Action
- type ActionCommit
- func (a *ActionCommit) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionCommit) Entry() Entry
- func (a *ActionCommit) EntryType() string
- func (a *ActionCommit) GetHeader() (header *Header)
- func (a *ActionCommit) Name() string
- func (a *ActionCommit) Receive(dht *DHT, msg *Message) (response interface{}, err error)
- func (a *ActionCommit) SetHeader(header *Header)
- func (a *ActionCommit) Share(h *Holochain, def *EntryDef) (err error)
- func (a *ActionCommit) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionDel
- func (a *ActionDel) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionDel) Entry() Entry
- func (a *ActionDel) EntryType() string
- func (a *ActionDel) GetHeader() (header *Header)
- func (a *ActionDel) Name() string
- func (a *ActionDel) Receive(dht *DHT, msg *Message) (response interface{}, err error)
- func (a *ActionDel) SetHeader(header *Header)
- func (a *ActionDel) Share(h *Holochain, def *EntryDef) (err error)
- func (a *ActionDel) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionGet
- type ActionGetLinks
- type ActionLink
- func (a *ActionLink) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionLink) Name() string
- func (a *ActionLink) Receive(dht *DHT, msg *Message) (response interface{}, err error)
- func (a *ActionLink) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionListAdd
- type ActionMigrate
- func (a *ActionMigrate) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionMigrate) Entry() Entry
- func (a *ActionMigrate) EntryType() string
- func (a *ActionMigrate) GetHeader() (header *Header)
- func (a *ActionMigrate) Name() string
- func (a *ActionMigrate) Receive(dht *DHT, msg *Message) (response interface{}, err error)
- func (a *ActionMigrate) SetHeader(header *Header)
- func (action *ActionMigrate) Share(h *Holochain, def *EntryDef) (err error)
- func (action *ActionMigrate) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionMod
- func (a *ActionMod) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionMod) Entry() Entry
- func (a *ActionMod) EntryType() string
- func (a *ActionMod) GetHeader() (header *Header)
- func (a *ActionMod) Name() string
- func (a *ActionMod) Receive(dht *DHT, msg *Message) (response interface{}, err error)
- func (a *ActionMod) SetHeader(header *Header)
- func (a *ActionMod) Share(h *Holochain, def *EntryDef) (err error)
- func (a *ActionMod) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionPut
- type ActionSend
- type Agent
- type AgentEntry
- type AgentFixture
- type AgentIdentity
- type AgentType
- type AppMsg
- type AppPackage
- type AppPackageScenario
- type AppPackageTests
- type AppPackageUIFile
- type Arg
- type ArgType
- type BSReq
- type BSResp
- type Bridge
- type BridgeApp
- type BridgeSpec
- type Bucket
- func (b *Bucket) Has(id peer.ID) bool
- func (b *Bucket) Len() int
- func (b *Bucket) MoveToFront(id peer.ID)
- func (b *Bucket) Peers() []peer.ID
- func (b *Bucket) PopBack() peer.ID
- func (b *Bucket) PushFront(p peer.ID)
- func (b *Bucket) Remove(id peer.ID)
- func (b *Bucket) Split(cpl int, target peer.ID) *Bucket
- type Bundle
- type BuntHT
- func (ht *BuntHT) Close()
- func (ht *BuntHT) Del(m *Message, key Hash) (err error)
- func (ht *BuntHT) DelLink(m *Message, base string, link string, tag string) (err error)
- func (ht *BuntHT) Exists(key Hash, statusMask int) (err error)
- func (ht *BuntHT) Get(key Hash, statusMask int, getMask int) (data []byte, entryType string, sources []string, status int, err error)
- func (ht *BuntHT) GetIdx() (idx int, err error)
- func (ht *BuntHT) GetIdxMessage(idx int) (msg Message, err error)
- func (ht *BuntHT) GetLinks(base Hash, tag string, statusMask int) (results []TaggedHash, err error)
- func (ht *BuntHT) Iterate(fn HashTableIterateFn)
- func (ht *BuntHT) JSON() (result string, err error)
- func (ht *BuntHT) Mod(m *Message, key Hash, newkey Hash) (err error)
- func (ht *BuntHT) Open(options interface{}) (err error)
- func (ht *BuntHT) Put(m *Message, entryType string, key Hash, src peer.ID, value []byte, status int) (err error)
- func (ht *BuntHT) PutLink(m *Message, base string, link string, tag string) (err error)
- func (ht *BuntHT) Source(key Hash) (id peer.ID, err error)
- func (ht *BuntHT) String() (result string)
- type BytesSent
- type Callback
- type Capability
- type Chain
- func (c *Chain) AddEntry(now time.Time, entryType string, e Entry, privKey ic.PrivKey) (hash Hash, err error)
- func (c *Chain) BundleStarted() *Bundle
- func (c *Chain) Close()
- func (c *Chain) CloseBundle(commit bool) (err error)
- func (c *Chain) Dot(start int) (dump string, err error)
- func (c *Chain) Dump(start int) string
- 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) JSON(start int) (string, error)
- func (c *Chain) Length() int
- func (c *Chain) MarshalChain(writer io.Writer, flags int64, whitelistTypes []string, privateTypes []string) (err error)
- func (c *Chain) Nth(n int) (header *Header)
- func (c *Chain) StartBundle(userParam interface{}) (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(skipEntries bool) (err error)
- func (c *Chain) Walk(fn WalkerFn) (err error)
- type ChainPair
- type Change
- type ChangeType
- type Channel
- type CloneSpec
- type CloserPeersResp
- type CommittingAction
- type Config
- type DHT
- func (dht *DHT) AddGossiper(id peer.ID) (err error)
- func (dht *DHT) Change(key Hash, msgType MsgType, body interface{}) (err error)
- func (dht *DHT) Close()
- func (dht *DHT) Del(m *Message, key Hash) (err error)
- func (dht *DHT) DelLink(m *Message, base string, link string, tag string) (err error)
- func (dht *DHT) DeleteGossiper(id peer.ID) (err error)
- func (dht *DHT) Exists(key Hash, statusMask int) (err error)
- func (dht *DHT) FindGossiper() (g peer.ID, err error)
- func (dht *DHT) Get(key Hash, statusMask int, getMask int) (data []byte, entryType string, sources []string, status int, err error)
- func (dht *DHT) GetFingerprint(f Hash) (index int, err error)
- func (dht *DHT) GetGossiper(id peer.ID) (idx int, err error)
- func (dht *DHT) GetGossipers() (gossipers []GossiperData, err error)
- func (dht *DHT) GetIdx() (idx int, err error)
- func (dht *DHT) GetIdxMessage(idx int) (msg Message, err error)
- func (dht *DHT) GetLinks(base Hash, tag string, statusMask int) (results []TaggedHash, err error)
- func (dht *DHT) GetPuts(since int) (puts []Put, err error)
- func (dht *DHT) HandleChangeRequests() (err error)
- func (dht *DHT) HandleGossipPuts() (err error)
- func (dht *DHT) HandleGossipWiths() (err error)
- func (dht *DHT) HaveFingerprint(f Hash) (result bool, err error)
- func (dht *DHT) Iterate(fn HashTableIterateFn)
- func (dht *DHT) JSON() (result string, err error)
- func (dht *DHT) MakeHoldResp(msg *Message, status int) (holdResp *HoldResp, err error)
- func (dht *DHT) MakeReceiptSignature(msg *Message, code int) (sig Signature, err error)
- func (dht *DHT) Mod(m *Message, key Hash, newkey Hash) (err error)
- func (dht *DHT) Open(options interface{}) (err error)
- func (dht *DHT) Put(m *Message, entryType string, key Hash, src peer.ID, value []byte, status int) (err error)
- func (dht *DHT) PutLink(m *Message, base string, link string, tag string) (err error)
- func (dht *DHT) Query(key Hash, msgType MsgType, body interface{}) (response interface{}, err error)
- func (dht *DHT) SetupDHT() (err error)
- func (dht *DHT) Source(key Hash) (id peer.ID, err error)
- func (dht *DHT) Start() (err error)
- func (dht *DHT) String() (result string)
- func (dht *DHT) UpdateGossiper(id peer.ID, newIdx int) (err error)
- type DHTConfig
- type DNA
- type DNAFile
- type DelEntry
- type Entry
- type EntryDef
- type EntryDefFile
- type ErrorResponse
- type FindNodeReq
- type FunctionDef
- type GetLinksOptions
- type GetOptions
- type GetReq
- type GetResp
- type GobEntry
- type Gossip
- type GossipReq
- type GossiperData
- type HashTable
- type HashTableIterateFn
- type HashType
- type Header
- type HoldReq
- type HoldResp
- type Holochain
- func (h *Holochain) Activate() (err error)
- func (h *Holochain) AddAgentEntry(revocation Revocation) (headerHash, agentHash Hash, err error)
- func (h *Holochain) AddBridgeAsCallee(fromDNA Hash, appData string) (token string, err error)
- func (h *Holochain) AddBridgeAsCaller(bridgeZome string, calleeDNA Hash, calleeName string, token string, url string, ...) (err error)
- func (h *Holochain) AddPeer(pi pstore.PeerInfo) (err error)
- func (h *Holochain) Agent() Agent
- func (h *Holochain) AgentHash() (id Hash)
- func (h *Holochain) AgentTopHash() (id Hash)
- func (h *Holochain) BSget() (err error)
- func (h *Holochain) BSpost() (err error)
- func (h *Holochain) BridgeCall(zomeType string, function string, arguments interface{}, token string) (result interface{}, err error)
- func (h *Holochain) BuildBridgeToCallee(app *BridgeApp) (err error)
- func (h *Holochain) BuildBridgeToCaller(app *BridgeApp, port string) (err error)
- func (h *Holochain) Call(zomeType string, function string, arguments interface{}, ...) (result interface{}, err error)
- func (h *Holochain) Chain() (n *Chain)
- func (h *Holochain) Close()
- func (h *Holochain) DBPath() string
- func (h *Holochain) DHT() *DHT
- func (h *Holochain) DNAHash() (id Hash)
- func (h *Holochain) DNAPath() string
- func (h *Holochain) Debug(m string)
- func (h *Holochain) Debugf(m string, args ...interface{})
- func (h *Holochain) EncodeDNA(writer io.Writer) (err error)
- func (h *Holochain) GenChain() (headerHash Hash, err error)
- func (h *Holochain) GetBridgeToken(hash Hash) (token string, url string, err error)
- func (h *Holochain) GetBridges() (bridges []Bridge, err error)
- func (h *Holochain) GetEntryDef(t string) (zome *Zome, d *EntryDef, err error)
- func (h *Holochain) GetPrivateEntryDefs() (privateDefs []EntryDef)
- func (h *Holochain) GetProperty(prop string) (property string, err error)
- func (h *Holochain) GetValidationResponse(a ValidatingAction, hash Hash) (resp ValidateResponse, err error)
- func (h *Holochain) GetZome(zName string) (z *Zome, err error)
- func (h *Holochain) HandleAsyncSends() (err error)
- func (h *Holochain) HandlePeerFound(pi pstore.PeerInfo)
- func (h *Holochain) HashSpec() HashSpec
- func (h *Holochain) MakeRibosome(t string) (r Ribosome, z *Zome, err error)
- func (h *Holochain) Name() string
- func (h *Holochain) NewEntry(now time.Time, entryType string, entry Entry) (hash Hash, header *Header, err error)
- func (h *Holochain) Node() *Node
- func (h *Holochain) NodeIDStr() string
- func (h *Holochain) Nucleus() (n *Nucleus)
- func (h *Holochain) Overlap(hash Hash) (overlap []peer.ID, err error)
- func (h *Holochain) Prepare() (err error)
- func (h *Holochain) PrepareHashType() (err error)
- func (h *Holochain) Query(options *QueryOptions) (results []QueryResult, err error)
- func (h *Holochain) RedundancyFactor() int
- func (h *Holochain) Reset() (err error)
- func (h *Holochain) RootPath() string
- func (h *Holochain) Send(basectx context.Context, proto int, to peer.ID, message *Message, ...) (response interface{}, err error)
- func (h *Holochain) SendAsync(proto int, to peer.ID, msg *Message, callback *Callback, timeout time.Duration) (err error)
- func (h *Holochain) Sign(data []byte) (signature Signature, err error)
- func (h *Holochain) StartBackgroundTasks()
- func (h *Holochain) Started() bool
- func (h *Holochain) TaskTicker(interval time.Duration, fn func(h *Holochain)) chan bool
- func (h *Holochain) TestPath() string
- func (h *Holochain) Top() (top Hash, err error)
- func (h *Holochain) UIPath() string
- func (h *Holochain) ValidateAction(a ValidatingAction, entryType string, pkg *Package, sources []peer.ID) (def *EntryDef, err error)
- func (h *Holochain) VerifySignature(signature Signature, data string, pubKey ic.PubKey) (matches bool, err error)
- func (h *Holochain) Walk(fn WalkerFn, entriesToo bool) (err error)
- func (h *Holochain) World() *World
- func (h *Holochain) ZomePath(z *Zome) string
- type JSONEntry
- type JSONSchemaValidator
- type JSRibosome
- func (jsr *JSRibosome) BridgeGenesis(side int, dnaHash Hash, data string) (err error)
- func (jsr *JSRibosome) BundleCanceled(reason string) (response string, err error)
- func (jsr *JSRibosome) Call(fn *FunctionDef, params interface{}) (result interface{}, err error)
- func (jsr *JSRibosome) ChainGenesis() (err error)
- func (jsr *JSRibosome) Receive(from string, msg string) (response string, err error)
- func (jsr *JSRibosome) Run(code string) (result interface{}, err error)
- func (jsr *JSRibosome) RunAsyncSendResponse(response AppMsg, callback string, callbackID string) (result interface{}, err error)
- func (jsr *JSRibosome) Type() string
- func (jsr *JSRibosome) ValidateAction(action Action, def *EntryDef, pkg *ValidationPackage, sources []string) (err error)
- func (jsr *JSRibosome) ValidatePackagingRequest(action ValidatingAction, def *EntryDef) (req PackagingReq, err error)
- type LibP2PAgent
- func (a *LibP2PAgent) AgentEntry(revocation Revocation) (entry AgentEntry, err error)
- func (a *LibP2PAgent) AgentType() AgentType
- func (a *LibP2PAgent) EncodePubKey() (b58pk string, err error)
- func (a *LibP2PAgent) GenKeys(seed io.Reader) (err error)
- func (a *LibP2PAgent) Identity() AgentIdentity
- func (a *LibP2PAgent) NodeID() (nodeID peer.ID, nodeIDStr string, err error)
- func (a *LibP2PAgent) PrivKey() ic.PrivKey
- func (a *LibP2PAgent) PubKey() ic.PubKey
- func (a *LibP2PAgent) SetIdentity(id AgentIdentity)
- type Link
- type LinkQuery
- type LinkQueryResp
- type LinksEntry
- type ListAddReq
- type Logger
- type Loggers
- type Message
- type MigrateEntry
- type ModAgentOptions
- type MsgType
- type Node
- func (node *Node) Block(addr peer.ID)
- func (node *Node) Close() error
- func (node *Node) Context() context.Context
- func (node *Node) Distance(id peer.ID) *big.Int
- func (n *Node) EnableMDNSDiscovery(h *Holochain, interval time.Duration) (err error)
- func (n *Node) ExternalAddr() ma.Multiaddr
- func (node *Node) FindLocal(id peer.ID) pstore.PeerInfo
- func (node *Node) FindPeer(ctx context.Context, id peer.ID) (pstore.PeerInfo, error)
- func (node *Node) GetClosestPeers(ctx context.Context, key Hash) (<-chan peer.ID, error)
- func (node *Node) InitBlockedList(list PeerList)
- func (node *Node) IsBlocked(addr peer.ID) (ok bool)
- func (node *Node) NewMessage(t MsgType, body interface{}) (msg *Message)
- func (node *Node) Process() goprocess.Process
- func (node *Node) Send(ctx context.Context, proto int, addr peer.ID, m *Message) (response Message, err error)
- func (node *Node) StartProtocol(h *Holochain, proto int) (err error)
- func (node *Node) Unblock(addr peer.ID)
- type NodeRecord
- type Nucleus
- type Package
- type PackagingReq
- type PeerInfo
- type PeerList
- type PeerListType
- type PeerRecord
- type Progenitor
- type Protocol
- type Put
- type QueryConstrain
- type QueryOptions
- type QueryOrder
- type QueryResult
- type QueryReturn
- type ReceiverFn
- type Revocation
- type Ribosome
- type RibosomeFactory
- type RoutingTable
- func (rt *RoutingTable) Find(id peer.ID) peer.ID
- func (rt *RoutingTable) IsEmpty() (empty bool)
- func (rt *RoutingTable) ListPeers() []peer.ID
- func (rt *RoutingTable) NearestPeer(hash Hash) peer.ID
- func (rt *RoutingTable) NearestPeers(hash Hash, count int) []peer.ID
- func (rt *RoutingTable) Print()
- func (rt *RoutingTable) Remove(p peer.ID)
- func (rt *RoutingTable) Size() int
- func (rt *RoutingTable) Update(p peer.ID)
- type SchemaValidator
- type SelfRevocation
- type SelfRevocationWarrant
- func (w *SelfRevocationWarrant) Decode(data []byte) (err error)
- func (w *SelfRevocationWarrant) Encode() (data []byte, err error)
- func (w *SelfRevocationWarrant) Parties() (parties []Hash, err error)
- func (w *SelfRevocationWarrant) Property(key string) (value interface{}, err error)
- func (w *SelfRevocationWarrant) Type() int
- func (w *SelfRevocationWarrant) Verify(h *Holochain) (err error)
- type SendOptions
- type Service
- func (s *Service) Clone(srcPath string, root string, agent Agent, new bool, initDB bool) (hP *Holochain, err error)
- func (s *Service) ConfiguredChains() (chains map[string]*Holochain, err error)
- func (s *Service) GenChain(name string) (h *Holochain, err error)
- func (service *Service) InitAppDir(root string, encodingFormat string) (err error)
- func (s *Service) IsConfigured(name string) (f string, err error)
- func (s *Service) ListChains() (list string)
- func (s *Service) Load(name string) (h *Holochain, err error)
- func (service *Service) MakeAppPackage(h *Holochain) (data []byte, err error)
- func (s *Service) MakeTestingApp(root string, encodingFormat string, initDB bool, newUUID bool, agent Agent) (h *Holochain, err error)
- func (service *Service) SaveFromAppPackage(reader io.Reader, path string, name string, agent Agent, decodingFormat string, ...) (appPackage *AppPackage, err error)
- type ServiceConfig
- type Signature
- type TaggedHash
- type TestConfig
- type TestData
- type TestFixtures
- type TestSet
- type ValidateQuery
- type ValidateResponse
- type ValidatingAction
- type ValidationPackage
- type WalkerFn
- type Warrant
- type World
- func (world *World) AddNode(pi pstore.PeerInfo, pubKey ic.PubKey) (err error)
- func (world *World) AllNodes() (nodes []peer.ID, err error)
- func (world *World) GetNodeRecord(ID peer.ID) (record *NodeRecord)
- func (world *World) IsHolding(ID peer.ID, hash Hash) (holding bool, err error)
- func (world *World) Responsible() (entries []Hash, err error)
- func (world *World) SetNodeHolding(ID peer.ID, hash Hash) (err error)
- func (world *World) UpdateResponsible(hash Hash, redundancy int) (responsible bool, err error)
- type Zome
- func (zome *Zome) CodeFileName() string
- func (z *Zome) GetEntryDef(entryName string) (e *EntryDef, err error)
- func (zome *Zome) GetFunctionDef(fnName string) (fn *FunctionDef, err error)
- func (z *Zome) GetPrivateEntryDefs() (privateDefs []EntryDef)
- func (zome *Zome) MakeRibosome(h *Holochain) (r Ribosome, err error)
- type ZomeFile
- type ZygoRibosome
- func (z *ZygoRibosome) BridgeGenesis(side int, dnaHash Hash, data string) (err error)
- func (z *ZygoRibosome) BundleCanceled(reason string) (response string, err error)
- func (z *ZygoRibosome) Call(fn *FunctionDef, params interface{}) (result interface{}, err error)
- func (z *ZygoRibosome) ChainGenesis() (err error)
- func (z *ZygoRibosome) Receive(from string, msg string) (response string, err error)
- func (z *ZygoRibosome) Run(code string) (result interface{}, err error)
- func (z *ZygoRibosome) RunAsyncSendResponse(response AppMsg, callback string, callbackID string) (result interface{}, err error)
- func (z *ZygoRibosome) Type() string
- func (z *ZygoRibosome) ValidateAction(action Action, def *EntryDef, pkg *ValidationPackage, sources []string) (err error)
- func (z *ZygoRibosome) ValidatePackagingRequest(action ValidatingAction, def *EntryDef) (req PackagingReq, err error)
Constants ¶
const ( HashArg = iota StringArg EntryArg // special arg type for entries, can be a string or a hash IntArg BoolArg MapArg ToStrArg // special arg type that converts anything to a string, used for the debug action ArgsArg // special arg type for arguments passed to the call action )
these constants define the argument types for actions, i.e. system functions callable from within nuclei
const ( DHTChangeOK = iota DHTChangeUnknownHashQueuedForRetry )
const ( ValidationFailureBadPublicKeyFormat = "bad public key format" ValidationFailureBadRevocationFormat = "bad revocation format" )
const ( ChainMarshalFlagsNone = 0x00 ChainMarshalFlagsNoHeaders = 0x01 ChainMarshalFlagsNoEntries = 0x02 ChainMarshalFlagsOmitDNA = 0x04 ChainMarshalFlagsNoPrivate = 0x08 ChainMarshalPrivateEntryRedacted = "%%PRIVATE ENTRY REDACTED%%" )
const ( GossipWithQueueSize = 10 GossipPutQueueSize = 1000 )
const ( SysEntryTypePrefix = "%" VirtualEntryTypePrefix = "%%" DataFormatJSON = "json" DataFormatString = "string" DataFormatRawJS = "js" DataFormatRawZygo = "zygo" Public = "public" Partial = "partial" Private = "private" )
const ( AgentEntryType = SysEntryTypePrefix + "agent" AgentEntrySchema = `` /* 651-byte string literal not displayed */ )
const ( DelEntryType = SysEntryTypePrefix + "del" DelEntrySchema = `` /* 466-byte string literal not displayed */ )
const ( DNAEntryType = SysEntryTypePrefix + "dna" DataFormatSysDNA = "_DNA" )
const ( // virtual entry type, not actually on the chain KeyEntryType = VirtualEntryTypePrefix + "key" DataFormatSysKey = "_key" )
const ( MigrateEntryType = SysEntryTypePrefix + "migrate" // currently both to/from have the same schema MigrateEntrySchema = `` /* 731-byte string literal not displayed */ // Type can only be one of two things... open or close MigrateEntryTypeClose = "close" MigrateEntryTypeOpen = "open" )
const ( // Version is the numeric version number of the holochain library Version int = 26 // VersionStr is the textual version number of the holochain library VersionStr string = "26" // DefaultSendTimeout a time.Duration to wait by default for send to complete DefaultSendTimeout = 3000 * time.Millisecond )
const ( AddLinkAction = "" DelLinkAction = "d" StatusDefault = 0x00 StatusLive = 0x01 StatusRejected = 0x02 StatusDeleted = 0x04 StatusModified = 0x08 StatusAny = 0xFF StatusLiveVal = "1" StatusRejectedVal = "2" StatusDeletedVal = "4" StatusModifiedVal = "8" StatusAnyVal = "255" SysTagReplacedBy = "__replacedBy" GetMaskDefault = 0x00 GetMaskEntry = 0x01 GetMaskEntryType = 0x02 GetMaskSources = 0x04 GetMaskAll = 0xFF GetMaskDefaultStr = "0" GetMaskEntryStr = "1" GetMaskEntryTypeStr = "2" GetMaskSourcesStr = "4" GetMaskAllStr = "255" )
const ( ReceiptOK = iota ReceiptRejected )
const ( JSRibosomeType = "js" ErrHandlingReturnErrorsStr = "returnErrorValue" ErrHandlingThrowErrorsStr = "throwErrors" )
const ( RetryingStopper = iota GossipingStopper BootstrappingStopper RefreshingStopper HoldingStopper )
const ( ActionProtocol = iota ValidateProtocol GossipProtocol KademliaProtocol )
const ( PeerTTL = time.Minute * 10 DefaultRoutingRefreshInterval = time.Minute DefaultGossipInterval = time.Second * 2 DefaultHoldingCheckInterval = time.Second * 30 )
const ( ErrUnknownCode = iota ErrHashNotFoundCode ErrHashDeletedCode ErrHashModifiedCode ErrHashRejectedCode ErrLinkNotFoundCode ErrEntryTypeMismatchCode ErrBlockedListedCode )
const ( STRING_CALLING = "string" JSON_CALLING = "json" // ZOME_EXPOSURE is the default and means the function is only exposed for use by other zomes in the app ZOME_EXPOSURE = "" // AUTHENTICATED_EXPOSURE means that the function is only available after authentication (TODO) AUTHENTICATED_EXPOSURE = "auth" // PUBLIC_EXPOSURE means that the function is callable by anyone PUBLIC_EXPOSURE = "public" ID_PROPERTY = "_id" AGENT_ID_PROPERTY = "_agent_id" AGENT_NAME_PROPERTY = "_agent_name" BridgeCaller = 0 BridgeCallee = 1 BridgeCallerStr = "0" BridgeCalleeStr = "1" BundleCancelReasonUserCancel = "userCancel" BundleCancelReasonTimeout = "timeout" BundleCancelResponseOK = "" BundleCancelResponseCommit = "commit" ValidationFailedErrMsg = "Validation Failed" )
const ( DefaultDirectoryName string = ".holochain" // Directory for storing config data ChainDataDir string = "db" // Sub-directory for all chain content files ChainDNADir string = "dna" // Sub-directory for all chain definition files ChainUIDir string = "ui" // Sub-directory for all chain user interface files ChainTestDir string = "test" // Sub-directory for all chain test files 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.db" // Filename for local data store DNAHashFileName string = "dna.hash" // Filename for storing the hash of the holochain DHTStoreFileName string = "dht.db" // Filname for storing the dht BridgeDBFileName string = "bridge.db" // Filname for storing bridge keys TestConfigFileName string = "_config.json" DefaultDHTPort = 6283 DefaultBootstrapServer = "bootstrap.holochain.net:10000" DefaultHashType HashType = HashType("sha2-256") // default hashing algo if not provided in DNA CloneWithNewUUID = true CloneWithSameUUID = false InitializeDB = true SkipInitializeDB = false )
System settings, directory, and file names
const ( SampleHTML = `` /* 821-byte string literal not displayed */ SampleJS = `` /* 440-byte string literal not displayed */ SampleBinary = `` /* 3713-byte string literal not displayed */ )
const ( OS_READ = 04 OS_WRITE = 02 OS_EX = 01 OS_USER_SHIFT = 6 OS_GROUP_SHIFT = 3 OS_OTH_SHIFT = 0 OS_USER_R = OS_READ << OS_USER_SHIFT OS_USER_W = OS_WRITE << OS_USER_SHIFT OS_USER_X = OS_EX << OS_USER_SHIFT OS_USER_RW = OS_USER_R | OS_USER_W OS_USER_RWX = OS_USER_RW | OS_USER_X OS_GROUP_R = OS_READ << OS_GROUP_SHIFT OS_GROUP_W = OS_WRITE << OS_GROUP_SHIFT OS_GROUP_X = OS_EX << OS_GROUP_SHIFT OS_GROUP_RW = OS_GROUP_R | OS_GROUP_W OS_GROUP_RWX = OS_GROUP_RW | OS_GROUP_X OS_OTH_R = OS_READ << OS_OTH_SHIFT OS_OTH_W = OS_WRITE << OS_OTH_SHIFT OS_OTH_X = OS_EX << OS_OTH_SHIFT OS_OTH_RW = OS_OTH_R | OS_OTH_W OS_OTH_RWX = OS_OTH_RW | OS_OTH_X OS_ALL_R = OS_USER_R | OS_GROUP_R | OS_OTH_R OS_ALL_W = OS_USER_W | OS_GROUP_W | OS_OTH_W OS_ALL_X = OS_USER_X | OS_GROUP_X | OS_OTH_X OS_ALL_RW = OS_ALL_R | OS_ALL_W OS_ALL_RWX = OS_ALL_RW | OS_GROUP_X )
const ( // PkgReqChain is the key who value is one of the PkgReqChainOptX masks PkgReqChain = "chain" // PkgReqEntryTypes is the key who value is an array of entry types to limit // the chain to PkgReqEntryTypes = "types" PkgReqChainOptNone = 0x00 PkgReqChainOptHeaders = 0x01 PkgReqChainOptEntries = 0x02 PkgReqChainOptFull = 0x03 PkgReqChainOptNoneStr = "0" PkgReqChainOptHeadersStr = "1" PkgReqChainOptEntriesStr = "2" PkgReqChainOptFullStr = "3" )
const (
AppPackageVersion = "0.0.1"
)
const (
BasicTemplateAppPackageFormat = "yml"
)
const (
BlockedList = "blockedlist"
)
const (
BootstrapTTL = time.Minute * 5
)
const (
DataFormatLinks = "links"
)
const (
DefaultBundleTimeout = 5000
)
const (
DefaultRetryInterval = time.Millisecond * 500
)
const (
GossipBackPutDelay = 100 * time.Millisecond
)
const (
HeadersEntrySchema = `` /* 2953-byte string literal not displayed */
)
const (
HeadersEntryType = SysEntryTypePrefix + "header"
)
const (
HolochainErrorPrefix = "HolochainError"
)
const ( JSLibrary = `var HC={Version:` + `"` + VersionStr + "\"" + `SysEntryType:{` + `DNA:"` + DNAEntryType + `",` + `Agent:"` + AgentEntryType + `",` + `Key:"` + KeyEntryType + `",` + `Headers:"` + HeadersEntryType + `"` + `Del:"` + DelEntryType + `"` + `Migrate:"` + MigrateEntryType + `"` + `}` + `HashNotFound:null` + `,Status:{Live:` + StatusLiveVal + `,Rejected:` + StatusRejectedVal + `,Deleted:` + StatusDeletedVal + `,Modified:` + StatusModifiedVal + `,Any:` + StatusAnyVal + "}" + `,GetMask:{Default:` + GetMaskDefaultStr + `,Entry:` + GetMaskEntryStr + `,EntryType:` + GetMaskEntryTypeStr + `,Sources:` + GetMaskSourcesStr + `,All:` + GetMaskAllStr + "}" + `,LinkAction:{Add:"` + AddLinkAction + `",Del:"` + DelLinkAction + `"}` + `,PkgReq:{Chain:"` + PkgReqChain + `"` + `,ChainOpt:{None:` + PkgReqChainOptNoneStr + `,Headers:` + PkgReqChainOptHeadersStr + `,Entries:` + PkgReqChainOptEntriesStr + `,Full:` + PkgReqChainOptFullStr + "}" + "}" + `,Bridge:{Caller:` + BridgeCallerStr + `,Callee:` + BridgeCalleeStr + "}" + `,BundleCancel:{` + `Reason:{UserCancel:"` + BundleCancelReasonUserCancel + `",Timeout:"` + BundleCancelReasonTimeout + `"},Response:{OK:"` + BundleCancelResponseOK + `",Commit:"` + BundleCancelResponseCommit + `"}}` + `Migrate:{Close:"` + MigrateEntryTypeClose + `",Open:"` + MigrateEntryTypeOpen + `"}` + `};` )
const (
LibP2P = iota
)
const (
MaxRetries = 10
)
const (
SelfRevocationType = iota
)
const (
TestingAppDecodingFormat = "json"
)
const ( ZygoLibrary = `(def HC_Version "` + VersionStr + `")` + `(def HC_HashNotFound nil)` + `(def HC_Status_Live ` + StatusLiveVal + ")" + `(def HC_Status_Rejected ` + StatusRejectedVal + ")" + `(def HC_Status_Deleted ` + StatusDeletedVal + ")" + `(def HC_Status_Modified ` + StatusModifiedVal + ")" + `(def HC_Status_Any ` + StatusAnyVal + ")" + `(def HC_GetMask_Default ` + GetMaskDefaultStr + ")" + `(def HC_GetMask_Entry ` + GetMaskEntryStr + ")" + `(def HC_GetMask_EntryType ` + GetMaskEntryTypeStr + ")" + `(def HC_GetMask_Sources ` + GetMaskSourcesStr + ")" + `(def HC_GetMask_All ` + GetMaskAllStr + ")" + `(def HC_Bridge_Caller ` + BridgeCallerStr + ")" + `(def HC_Bridge_Callee ` + BridgeCalleeStr + ")" + `(def HC_LinkAction_Add "` + AddLinkAction + "\")" + `(def HC_LinkAction_Del "` + DelLinkAction + "\")" + `(def HC_PkgReq_Chain "` + PkgReqChain + "\")" + `(def HC_PkgReq_ChainOpt_None "` + PkgReqChainOptNoneStr + "\")" + `(def HC_PkgReq_ChainOpt_Headers "` + PkgReqChainOptHeadersStr + "\")" + `(def HC_PkgReq_ChainOpt_Entries "` + PkgReqChainOptEntriesStr + "\")" + `(def HC_PkgReq_ChainOpt_Full "` + PkgReqChainOptFullStr + "\")" + `(def HC_Migrate_Close "` + MigrateEntryTypeClose + `")` + `(def HC_Migrate_Open "` + MigrateEntryTypeOpen + `")` )
These are the zygo implementations of the library functions that must available in all Ribosome implementations.
const (
ZygoRibosomeType = "zygo"
)
Variables ¶
var AgentEntryDef = &EntryDef{Name: AgentEntryType, DataFormat: DataFormatJSON, Sharing: Public, Schema: AgentEntrySchema}
var AlphaValue int = 3
var BasicTemplateAppPackage string = `{ # AppPackage Version # The app package schema version of this file. "Version": "` + AppPackageVersion + `", "Generator": "holochain", "DNA": { # This is a holochain application package yaml definition. http://ceptr.org/projects/holochain # DNA File Version # Version indicator for changes to DNA "Version": 1, # DNA Unique ID # This ID differentiates your app from others. For example, to tell one Slack team from another with same code, so change it! "UUID": "00000000-0000-0000-0000-000000000000", # Application Name # What would you like to call your holochain app? "Name": "templateApp", # Requires Holochain Version # Version indicator for which minimal version of holochain is required by this DNA "RequiresVersion": ` + VersionStr + `, # Properties # Properties that you want available across all Zomes. "Properties": { # Application Description # Briefly describe your holochain app. "description": "provides an application template", # Language # The base (human) language of this holochain app. "language": "en" }, # Properties Schema File # Describes the entries in the Properties section of your dna file. "PropertiesSchemaFile": "properties_schema.json", # DHT Settings # Configure the properties of your Distributed Hash Table (e.g. hash algorithm, neighborhood size, etc.). "DHTConfig": { "HashType": "sha2-256" }, # Zomes # List the Zomes your application will support. "Zomes": [ { # Zome Name # The name of this code module. "Name": "sampleZome", # Zome Description # What is the purpose of this module? "Description": "provide a sample zome", # Ribosome Type # What scripting language will you code in? "RibosomeType": "js", # Zome Entries # Data stored and tracked by your Zome. "Entries": [ { "Name": "sampleEntry", # The name of this entry. "Required": true, # Is this entry required? "DataFormat": "json", # What type of data should this entry store? "Sharing": "public", # Should this entry be publicly accessible? "Schema": "{\n \"title\": \"sampleEntry Schema\",\n \"type\": \"object\",\n \"properties\": {\n \"content\": {\n \"type\": \"string\"\n },\n \"timestamp\": {\n \"type\": \"integer\"\n }\n },\n \"required\": [\"content\", \"timestamp\"]\n}" } ], # Zome Functions # Functions which can be called in your Zome's API. "Functions": [ { "Name": "sampleEntryCreate", # The name of this function. "CallingType": "json", # Data format for parameters passed to this function. "Exposure": "public" # Level to which is this function exposed. }, { "Name": "sampleEntryRead", # The name of this function. "CallingType": "json", # Data format for parameters passed to this function. "Exposure": "public" # Level to which is this function exposed. }, { "Name": "doSampleAction", # The name of this function. "CallingType": "json", # Data format for parameters passed to this function. "Exposure": "public" # Level to which is this function exposed. } ], # Zome Source Code # The logic that will control Zome behavior "Code": "/*******************************************************************************\n * Utility functions\n ******************************************************************************/\n\n/**\n * Is this a valid entry type?\n *\n * @param {any} entryType The data to validate as an expected entryType.\n * @return {boolean} true if the passed argument is a valid entryType.\n */\nfunction isValidEntryType (entryType) {\n // Add additonal entry types here as they are added to dna.json.\n return [\"sampleEntry\"].includes(entryType);\n}\n\n/**\n * Returns the creator of an entity, given an entity hash.\n *\n * @param {string} hash The entity hash.\n * @return {string} The agent hash of the entity creator.\n */\nfunction getCreator (hash) {\n return get(hash, { GetMask: HC.GetMask.Sources })[0];\n}\n\n/*******************************************************************************\n * Required callbacks\n ******************************************************************************/\n\n/**\n * System genesis callback: Can the app start?\n *\n * Executes just after the initial genesis entries are committed to your chain\n * (1st - DNA entry, 2nd Identity entry). Enables you specify any additional\n * operations you want performed when a node joins your holochain.\n *\n * @return {boolean} true if genesis is successful and so the app may start.\n *\n * @see https://developer.holochain.org/API#genesis\n */\nfunction genesis () {\n return true;\n}\n\n/**\n * Validation callback: Can this entry be committed to a source chain?\n *\n * @param {string} entryType Type of the entry as per DNA config for this zome.\n * @param {string|object} entry Data with type as per DNA config for this zome.\n * @param {Header-object} header Header object for this entry.\n * @param {Package-object|null} pkg Package object for this entry, if exists.\n * @param {string[]} sources Array of agent hashes involved in this commit.\n * @return {boolean} true if this entry may be committed to a source chain.\n *\n * @see https://developer.holochain.org/API#validateCommit_entryType_entry_header_package_sources\n * @see https://developer.holochain.org/Validation_Functions\n */\nfunction validateCommit (entryType, entry, header, pkg, sources) {\n return isValidEntryType(entryType);\n}\n\n/**\n * Validation callback: Can this entry be committed to the DHT on any node?\n *\n * It is very likely that this validation routine should check the same data\n * integrity as validateCommit, but, as it happens during a different part of\n * the data life-cycle, it may require additional validation steps.\n *\n * This function will only get called on entry types with \"public\" sharing, as\n * they are the only types that get put to the DHT by the system.\n *\n * @param {string} entryType Type of the entry as per DNA config for this zome.\n * @param {string|object} entry Data with type as per DNA config for this zome.\n * @param {Header-object} header Header object for this entry.\n * @param {Package-object|null} pkg Package object for this entry, if exists.\n * @param {string[]} sources Array of agent hashes involved in this commit.\n * @return {boolean} true if this entry may be committed to the DHT.\n *\n * @see https://developer.holochain.org/API#validatePut_entryType_entry_header_package_sources\n * @see https://developer.holochain.org/Validation_Functions\n */\nfunction validatePut (entryType, entry, header, pkg, sources) {\n return validateCommit(entryType, entry, header, pkg, sources);\n}\n\n/**\n * Validation callback: Can this entry be modified?\n *\n * Validate that this entry can replace 'replaces' due to 'mod'.\n *\n * @param {string} entryType Type of the entry as per DNA config for this zome.\n * @param {string|object} entry Data with type as per DNA config for this zome.\n * @param {Header-object} header Header object for this entry.\n * @param {string} replaces The hash string of the entry being replaced.\n * @param {Package-object|null} pkg Package object for this entry, if exists.\n * @param {string[]} sources Array of agent hashes involved in this mod.\n * @return {boolean} true if this entry may replace 'replaces'.\n *\n * @see https://developer.holochain.org/API#validateMod_entryType_entry_header_replaces_package_sources\n * @see https://developer.holochain.org/Validation_Functions\n */\nfunction validateMod (entryType, entry, header, replaces, pkg, sources) {\n return validateCommit(entryType, entry, header, pkg, sources)\n // Only allow the creator of the entity to modify it.\n && getCreator(header.EntryLink) === getCreator(replaces);\n}\n\n/**\n * Validation callback: Can this entry be deleted?\n *\n * @param {string} entryType Name of the entry as per DNA config for this zome.\n * @param {string} hash The hash of the entry to be deleted.\n * @param {Package-object|null} pkg Package object for this entry, if exists.\n * @param {string[]} sources Array of agent hashes involved in this delete.\n * @return {boolean} true if this entry can be deleted.\n *\n * @see https://developer.holochain.org/API#validateDel_entryType_hash_package_sources\n * @see https://developer.holochain.org/Validation_Functions\n */\nfunction validateDel (entryType, hash, pkg, sources) {\n return isValidEntryType(entryType)\n // Only allow the creator of the entity to delete it.\n && getCreator(hash) === sources[0];\n}\n\n/**\n * Package callback: The package request for validateCommit() and valdiatePut().\n *\n * Both 'commit' and 'put' trigger 'validatePutPkg' as 'validateCommit' and\n * 'validatePut' must both have the same data.\n *\n * @param {string} entryType Name of the entry as per DNA config for this zome.\n * @return {PkgReq-object|null}\n * null if the data required is the Entry and Header.\n * Otherwise a \"Package Request\" object, which specifies what data to be sent\n * to the validating node.\n *\n * @see https://developer.holochain.org/API#validatePutPkg_entryType\n * @see https://developer.holochain.org/Validation_Packaging\n */\nfunction validatePutPkg (entryType) {\n return null;\n}\n\n/**\n * Package callback: The package request for validateMod().\n *\n * @param {string} entryType Name of the entry as per DNA config for this zome.\n * @return {PkgReq-object|null}\n * null if the data required is the Entry and Header.\n * Otherwise a \"Package Request\" object, which specifies what data to be sent\n * to the validating node.\n *\n * @see https://developer.holochain.org/API#validateModPkg_entryType\n * @see https://developer.holochain.org/Validation_Packaging\n */\nfunction validateModPkg (entryType) {\n return null;\n}\n\n/**\n * Package callback: The package request for validateDel().\n *\n * @param {string} entryType Name of the entry as per DNA config for this zome.\n * @return {PkgReq-object|null}\n * null if the data required is the Entry and Header.\n * Otherwise a \"Package Request\" object, which specifies what data to be sent\n * to the validating node.\n *\n * @see https://developer.holochain.org/API#validateDelPkg_entryType\n * @see https://developer.holochain.org/Validation_Packaging\n */\nfunction validateDelPkg (entryType) {\n return null;\n}" } ]}, "TestSets":[{ "Name":"sample", "TestSet":{"Tests":[{"Convey":"Example: (which fails because we haven't actually implemented a sampleEntryCreate function) We can create a new sampleEntry","Zome":"sampleZome","FnName": "sampleEntryCreate","Input": {"content": "this is the entry body","stamp":12345},"Output":"\"%h1%\"","Exposure":"public"}]}} ], "UI":[ {"FileName":"index.html", "Data":"<html><body>Your UI here!</body></html>" }, {"FileName":"hc.js", "Data":"function yourApp(){alert('your UI code here!')}" }], "Scenarios":[ {"Name":"sampleScenario", "Roles":[ {"Name":"listener", "TestSet":{"Tests":[ {"Convey":"add listener test here"}]}}, {"Name":"speaker", "TestSet":{"Tests":[ {"Convey":"add speaker test here"}]}}], "Config":{"Duration":5,"GossipInterval":100}}] } `
var BridgeAppNotFoundErr = errors.New("bridge app not found")
var BytesSentChan chan BytesSent
var CapabilityInvalidErr = errors.New("invalid capability")
var ChangeAppProperty = Change{ Type: Warning, Message: "Getting special properties via property() is deprecated as of %d. Returning nil values. Use App* instead", AsOf: 3, }
var CloserPeerCount = KValue
The number of closer peers to send on requests.
var Crash bool
var DNAEntryDef = &EntryDef{Name: DNAEntryType, DataFormat: DataFormatSysDNA}
var DelEntryDef = &EntryDef{Name: DelEntryType, DataFormat: DataFormatJSON, Sharing: Public, Schema: DelEntrySchema}
var EnableAllLoggersEnv string = "HC_ENABLE_ALL_LOGS"
var ErrActionMissingHeader error = errors.New("Action is missing header")
var ErrActionReceiveInvalid error = errors.New("Action receive is invalid")
var ErrBlockedListed = errors.New("node blockedlisted")
var ErrBundleNotStarted = errors.New("bundle not started")
var ErrChainLockedForBundle = errors.New("chain locked for bundle")
var ErrDHTErrNoGossipersAvailable error = errors.New("no gossipers available")
var ErrDHTExpectedGossipReqInBody error = errors.New("expected gossip request")
var ErrDHTUnexpectedTypeInBody error = errors.New("unexpected type in message body")
var ErrEmptyRoutingTable = errors.New("routing table empty")
var ErrEntryDefInvalid = errors.New("Invalid Entry Defintion")
var ErrEntryTypeMismatch = errors.New("entry type mismatch")
var ErrHashDeleted = errors.New("hash deleted")
var ErrHashModified = errors.New("hash modified")
var ErrHashNotFound = errors.New("hash not found")
var ErrHashRejected = errors.New("hash rejected")
var ErrIncompleteChain = errors.New("operation not allowed on incomplete chain")
var ErrLinkNotFound = errors.New("link not found")
var ErrModInvalidForLinks error = errors.New("mod: invalid for Links entry")
var ErrModMissingHeader error = errors.New("mod: missing header")
var ErrModReplacesHashNotDifferent error = errors.New("mod: replaces must be different from original hash")
var ErrNilEntryInvalid error = errors.New("nil entry invalid")
var ErrNoSuchIdx error = errors.New("no such change index")
var ErrNodeNotFound = errors.New("node not found")
var ErrNotAcceptedByAnyRemoteNode = errors.New("Change not accepted by any remote node")
var ErrNotValidForAgentType error = errors.New("Invalid action for Agent type")
var ErrNotValidForDNAType error = errors.New("Invalid action for DNA type")
var ErrNotValidForDelType error = errors.New("Invalid action for Del type")
var ErrNotValidForHeadersType error = errors.New("Invalid action for Headers type")
var ErrNotValidForKeyType error = errors.New("Invalid action for Key type")
var ErrPutLinkOverDeleted = errors.New("putlink over deleted link")
var ErrWrongNargs = errors.New("wrong number of arguments")
var HeadersEntryDef = &EntryDef{Name: HeadersEntryType, DataFormat: DataFormatJSON, Sharing: Public, Schema: HeadersEntrySchema}
var KValue int = 10
var KeyEntryDef = &EntryDef{Name: KeyEntryType, DataFormat: DataFormatSysKey}
var MigrateEntryDef = &EntryDef{Name: MigrateEntryType, DataFormat: DataFormatJSON, Sharing: Public, Schema: MigrateEntrySchema}
var NonDHTAction error = errors.New("Not a DHT action")
var SelfRevocationDoesNotVerify = errors.New("self revocation does not verify")
var SendTimeoutErr = errors.New("send timeout")
var UnknownWarrantTypeErr = errors.New("unknown warrant type")
var ValidationFailedErr = errors.New(ValidationFailedErrMsg)
var WarrantPropertyNotFoundErr = errors.New("warrant property not found")
Functions ¶
func ActionReceiver ¶
ActionReceiver handles messages on the action protocol
func BootstrapRefreshTask ¶
func BootstrapRefreshTask(h *Holochain)
BootstrapRefreshTask refreshes our node and gets nodes from the bootstrap server
func ByteDecoder ¶
ByteDecoder decodes data encoded by ByteEncoder
func ByteEncoder ¶
ByteEncoder encodes anything using gob
func CleanupTestChain ¶
func CleanupTestDir ¶
func CleanupTestDir(path string)
func CopyDir ¶
CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist.
func DNAHashofUngenedChain ¶
func Debugf ¶
func Debugf(m string, args ...interface{})
Debugf sends a formatted string to the global debug log
func DebuggingRequestedViaEnv ¶
func DebuggingRequestedViaEnv() (val, yes bool)
DebuggingRequestedViaEnv determines whether an environment var was set to enable or disable debugging
func DecodeFile ¶
DecodeFile decodes a file based on the extension and the data type
func EncodingFormat ¶
EncodingFormat returns the files format if supported otherwise ""
func EscapeJSONValue ¶
EscapeJSONValue removed characters from a JSON value to avoid parsing issues.
func FileExists ¶
func GetAllTestRoles ¶
GetAllTestRoles retuns a list of the roles in a scenario
func GetTestScenarioRoles ¶
GetTestScenarioRoles returns a list of scenario roles
func GetTestScenarios ¶
TestScenarioList returns a list of paths to scenario directories
func GossipReceiver ¶
GossipReceiver implements the handler for the gossip protocol
func HoldingTask ¶
func HoldingTask(h *Holochain)
func Infof ¶
func Infof(m string, args ...interface{})
Infof sends a formatted string to the standard info log
func InitializeHolochain ¶
func InitializeHolochain()
InitializeHolochain setup function that must be called once at startup by the application that uses this holochain library
func IsInitialized ¶
IsInitialized checks a path for a correctly set up .holochain directory
func IsValidationFailedErr ¶
func KademliaReceiver ¶
KademliaReceiver implements the handler for the kademlia RPC protocol messages
func LoadTestFiles ¶
LoadTestFiles searches a path for .json test files and loads them into an array
func MakeReceiptData ¶
MakeReceiptData converts a message and a code into signable data
func MakeTestDirName ¶
func MakeTestDirName() string
func MakeTestSeed ¶
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 NormaliseJSON ¶
func PrettyPrintJSON ¶
PrettyPrintJSON for human reability.
func RegisterBultinRibosomes ¶
func RegisterBultinRibosomes()
RegisterBultinRibosomes adds the built in ribosome types to the factory hash
func RegisterRibosome ¶
func RegisterRibosome(name string, factory RibosomeFactory)
RegisterRibosome sets up a Ribosome to be used by the CreateRibosome function
func RetryTask ¶
func RetryTask(h *Holochain)
RetryTask checks to see if there are any received puts that need retrying and does one if so
func RoutingRefreshTask ¶
func RoutingRefreshTask(h *Holochain)
RoutingRefreshTask fills the routing table by searching for a random node
func RunValidationPhase ¶
func SetAgentIdentity ¶
func SetAgentIdentity(agent Agent, identity AgentIdentity)
func SetIdentity ¶
func SetIdentity(h *Holochain, identity AgentIdentity)
func SetupTestDir ¶
func SetupTestDir() string
func TestingAppAppPackage ¶
func TestingAppAppPackage() string
func Ticker ¶
Ticker runs a function on an interval that can be stopped with the returned bool channel
func UnmarshalHeader ¶
UnmarshalHeader reads a Header from a binary stream
func UnmarshalSignature ¶
UnmarshalSignature reads a Signature from a binary stream
func ValidateReceiver ¶
ValidateReceiver handles messages on the Validate protocol
func ValidationFailed ¶
ValidationFailed creates a validation failed error message
Types ¶
type APIFnBridge ¶
type APIFnBridge struct {
// contains filtered or unexported fields
}
func (*APIFnBridge) Args ¶
func (fn *APIFnBridge) Args() []Arg
func (*APIFnBridge) Call ¶
func (fn *APIFnBridge) Call(h *Holochain) (response interface{}, err error)
func (*APIFnBridge) Name ¶
func (fn *APIFnBridge) Name() string
type APIFnCloseBundle ¶
type APIFnCloseBundle struct {
// contains filtered or unexported fields
}
func (*APIFnCloseBundle) Args ¶
func (a *APIFnCloseBundle) Args() []Arg
func (*APIFnCloseBundle) Call ¶
func (a *APIFnCloseBundle) Call(h *Holochain) (response interface{}, err error)
func (*APIFnCloseBundle) Name ¶
func (a *APIFnCloseBundle) Name() string
type APIFnCommit ¶
type APIFnCommit struct {
// contains filtered or unexported fields
}
func (*APIFnCommit) Args ¶
func (fn *APIFnCommit) Args() []Arg
func (*APIFnCommit) Call ¶
func (fn *APIFnCommit) Call(h *Holochain) (response interface{}, err error)
func (*APIFnCommit) Name ¶
func (fn *APIFnCommit) Name() string
func (*APIFnCommit) SetAction ¶
func (fn *APIFnCommit) SetAction(a *ActionCommit)
type APIFnDebug ¶
type APIFnDebug struct {
// contains filtered or unexported fields
}
func (*APIFnDebug) Args ¶
func (a *APIFnDebug) Args() []Arg
func (*APIFnDebug) Call ¶
func (a *APIFnDebug) Call(h *Holochain) (response interface{}, err error)
func (*APIFnDebug) Name ¶
func (a *APIFnDebug) Name() string
type APIFnGetBridges ¶
type APIFnGetBridges struct { }
func (*APIFnGetBridges) Args ¶
func (a *APIFnGetBridges) Args() []Arg
func (*APIFnGetBridges) Call ¶
func (a *APIFnGetBridges) Call(h *Holochain) (response interface{}, err error)
func (*APIFnGetBridges) Name ¶
func (a *APIFnGetBridges) Name() string
type APIFnGetLinks ¶
type APIFnGetLinks struct {
// contains filtered or unexported fields
}
func (*APIFnGetLinks) Args ¶
func (fn *APIFnGetLinks) Args() []Arg
func (*APIFnGetLinks) Call ¶
func (fn *APIFnGetLinks) Call(h *Holochain) (response interface{}, err error)
func (*APIFnGetLinks) Name ¶
func (fn *APIFnGetLinks) Name() string
type APIFnMakeHash ¶
type APIFnMakeHash struct {
// contains filtered or unexported fields
}
func (*APIFnMakeHash) Args ¶
func (a *APIFnMakeHash) Args() []Arg
func (*APIFnMakeHash) Call ¶
func (a *APIFnMakeHash) Call(h *Holochain) (response interface{}, err error)
func (*APIFnMakeHash) Name ¶
func (a *APIFnMakeHash) Name() string
type APIFnMigrate ¶
type APIFnMigrate struct {
// contains filtered or unexported fields
}
func (*APIFnMigrate) Args ¶
func (fn *APIFnMigrate) Args() []Arg
func (*APIFnMigrate) Call ¶
func (fn *APIFnMigrate) Call(h *Holochain) (response interface{}, err error)
func (*APIFnMigrate) Name ¶
func (fn *APIFnMigrate) Name() string
type APIFnModAgent ¶
type APIFnModAgent struct { Identity AgentIdentity Revocation string }
func (*APIFnModAgent) Args ¶
func (fn *APIFnModAgent) Args() []Arg
func (*APIFnModAgent) Call ¶
func (fn *APIFnModAgent) Call(h *Holochain) (response interface{}, err error)
func (*APIFnModAgent) Name ¶
func (fn *APIFnModAgent) Name() string
type APIFnProperty ¶
type APIFnProperty struct {
// contains filtered or unexported fields
}
func (*APIFnProperty) Args ¶
func (a *APIFnProperty) Args() []Arg
func (*APIFnProperty) Call ¶
func (a *APIFnProperty) Call(h *Holochain) (response interface{}, err error)
func (*APIFnProperty) Name ¶
func (a *APIFnProperty) Name() string
type APIFnQuery ¶
type APIFnQuery struct {
// contains filtered or unexported fields
}
func (*APIFnQuery) Args ¶
func (a *APIFnQuery) Args() []Arg
func (*APIFnQuery) Call ¶
func (a *APIFnQuery) Call(h *Holochain) (response interface{}, err error)
func (*APIFnQuery) Name ¶
func (a *APIFnQuery) Name() string
type APIFnStartBundle ¶
type APIFnStartBundle struct {
// contains filtered or unexported fields
}
func NewStartBundleAction ¶
func NewStartBundleAction(timeout int, userParam string) *APIFnStartBundle
func (*APIFnStartBundle) Args ¶
func (a *APIFnStartBundle) Args() []Arg
func (*APIFnStartBundle) Call ¶
func (a *APIFnStartBundle) Call(h *Holochain) (response interface{}, err error)
func (*APIFnStartBundle) Name ¶
func (a *APIFnStartBundle) Name() string
type APIFnVerifySignature ¶
type APIFnVerifySignature struct {
// contains filtered or unexported fields
}
func (*APIFnVerifySignature) Args ¶
func (a *APIFnVerifySignature) Args() []Arg
func (*APIFnVerifySignature) Call ¶
func (a *APIFnVerifySignature) Call(h *Holochain) (response interface{}, err error)
func (*APIFnVerifySignature) Name ¶
func (a *APIFnVerifySignature) Name() string
type APIFunction ¶
type APIFunction interface { Name() string Args() []Arg Call(h *Holochain) (response interface{}, err error) }
APIFunction abstracts the argument structure and the calling of an api function
type Action ¶
type Action interface { Name() string Receive(dht *DHT, msg *Message) (response interface{}, err error) }
Action provides an abstraction for handling node interaction
func MakeActionFromMessage ¶
MakeActionFromMessage generates an action from an action protocol messsage
type ActionCommit ¶
type ActionCommit struct {
// contains filtered or unexported fields
}
func NewCommitAction ¶
func NewCommitAction(entryType string, entry Entry) *ActionCommit
func (*ActionCommit) CheckValidationRequest ¶
func (a *ActionCommit) CheckValidationRequest(def *EntryDef) (err error)
func (*ActionCommit) Entry ¶
func (a *ActionCommit) Entry() Entry
func (*ActionCommit) EntryType ¶
func (a *ActionCommit) EntryType() string
func (*ActionCommit) GetHeader ¶
func (a *ActionCommit) GetHeader() (header *Header)
func (*ActionCommit) Name ¶
func (a *ActionCommit) Name() string
func (*ActionCommit) Receive ¶
func (a *ActionCommit) Receive(dht *DHT, msg *Message) (response interface{}, err error)
func (*ActionCommit) SetHeader ¶
func (a *ActionCommit) SetHeader(header *Header)
func (*ActionCommit) SysValidation ¶
type ActionDel ¶
type ActionDel struct {
// contains filtered or unexported fields
}
func NewDelAction ¶
func (*ActionDel) CheckValidationRequest ¶
type ActionGet ¶
type ActionGet struct {
// contains filtered or unexported fields
}
type ActionGetLinks ¶
type ActionGetLinks struct {
// contains filtered or unexported fields
}
func NewGetLinksAction ¶
func NewGetLinksAction(linkQuery *LinkQuery, options *GetLinksOptions) *ActionGetLinks
func (*ActionGetLinks) Name ¶
func (a *ActionGetLinks) Name() string
func (*ActionGetLinks) Receive ¶
func (a *ActionGetLinks) Receive(dht *DHT, msg *Message) (response interface{}, err error)
func (*ActionGetLinks) SysValidation ¶
type ActionLink ¶
type ActionLink struct {
// contains filtered or unexported fields
}
func NewLinkAction ¶
func NewLinkAction(entryType string, links []Link) *ActionLink
func (*ActionLink) CheckValidationRequest ¶
func (a *ActionLink) CheckValidationRequest(def *EntryDef) (err error)
func (*ActionLink) Name ¶
func (a *ActionLink) Name() string
func (*ActionLink) Receive ¶
func (a *ActionLink) Receive(dht *DHT, msg *Message) (response interface{}, err error)
func (*ActionLink) SysValidation ¶
type ActionListAdd ¶
type ActionListAdd struct {
// contains filtered or unexported fields
}
func NewListAddAction ¶
func NewListAddAction(peerList PeerList) *ActionListAdd
func (*ActionListAdd) Name ¶
func (a *ActionListAdd) Name() string
type ActionMigrate ¶
type ActionMigrate struct {
// contains filtered or unexported fields
}
func (*ActionMigrate) CheckValidationRequest ¶
func (a *ActionMigrate) CheckValidationRequest(def *EntryDef) (err error)
func (*ActionMigrate) Entry ¶
func (a *ActionMigrate) Entry() Entry
func (*ActionMigrate) EntryType ¶
func (a *ActionMigrate) EntryType() string
func (*ActionMigrate) GetHeader ¶
func (a *ActionMigrate) GetHeader() (header *Header)
func (*ActionMigrate) Name ¶
func (a *ActionMigrate) Name() string
func (*ActionMigrate) Receive ¶
func (a *ActionMigrate) Receive(dht *DHT, msg *Message) (response interface{}, err error)
func (*ActionMigrate) SetHeader ¶
func (a *ActionMigrate) SetHeader(header *Header)
func (*ActionMigrate) Share ¶
func (action *ActionMigrate) Share(h *Holochain, def *EntryDef) (err error)
func (*ActionMigrate) SysValidation ¶
type ActionMod ¶
type ActionMod struct {
// contains filtered or unexported fields
}
func NewModAction ¶
func (*ActionMod) CheckValidationRequest ¶
type ActionPut ¶
type ActionPut struct {
// contains filtered or unexported fields
}
func (*ActionPut) CheckValidationRequest ¶
type ActionSend ¶
type ActionSend struct {
// contains filtered or unexported fields
}
func (*ActionSend) Name ¶
func (a *ActionSend) Name() string
type Agent ¶
type Agent interface { Identity() AgentIdentity SetIdentity(id AgentIdentity) AgentType() AgentType GenKeys(seed io.Reader) error PrivKey() ic.PrivKey PubKey() ic.PubKey EncodePubKey() (string, error) NodeID() (peer.ID, string, error) AgentEntry(revocation Revocation) (AgentEntry, error) }
Agent abstracts the key behaviors and connection to a holochain node address Note that this is currently only a partial abstraction because the NodeID is always a libp2p peer.ID to complete the abstraction so we could use other libraries for p2p2 network transaction we would need to also abstract a matching NodeID type
type AgentEntry ¶
type AgentEntry struct { Identity AgentIdentity Revocation string // marshaled revocation PublicKey string // marshaled public key }
AgentEntry structure for building AgentEntryType entries
func AgentEntryFromJSON ¶
func AgentEntryFromJSON(j string) (entry AgentEntry, err error)
func (*AgentEntry) ToJSON ¶
func (ae *AgentEntry) ToJSON() (encodedEntry string, err error)
type AgentFixture ¶
AgentFixture defines an agent for the purposes of tests
type AgentIdentity ¶
type AgentIdentity string
AgentIdentity is the user's unique identity information in context of this holochain. it follows AgentIdentitySchema in DNA
type AppPackage ¶
type AppPackage struct { Version string Generator string DNA DNA TestSets []AppPackageTests UI []AppPackageUIFile Scenarios []AppPackageScenario }
func LoadAppPackage ¶
func LoadAppPackage(reader io.Reader, encodingFormat string) (appPackageP *AppPackage, err error)
LoadAppPackage decodes DNA and other appPackage data from appPackage file (via an io.reader)
type AppPackageScenario ¶
type AppPackageScenario struct { Name string Roles []AppPackageTests Config TestConfig }
type AppPackageTests ¶
type AppPackageUIFile ¶
type Arg ¶
type Arg struct { Name string Type ArgType Optional bool MapType reflect.Type // contains filtered or unexported fields }
Arg holds the definition of an API function argument
type BridgeApp ¶
type BridgeApp struct { Name string //Name of other side DNA Hash // DNA of other side Side int BridgeGenesisCallerData string BridgeGenesisCalleeData string Port string // only used if side == BridgeCallee BridgeZome string // only used if side == BridgeCaller }
BridgeApp describes a data necessary for bridging
type BridgeSpec ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket holds a list of peers.
func (*Bucket) MoveToFront ¶
type BuntHT ¶
type BuntHT struct {
// contains filtered or unexported fields
}
func (*BuntHT) Del ¶
Del moves the given hash to the StatusDeleted status N.B. this functions assumes that the validity of this action has been confirmed
func (*BuntHT) DelLink ¶
DelLink removes a link and tag associated with a stored hash N.B. this function assumes that the action has been properly validated
func (*BuntHT) Get ¶
func (ht *BuntHT) Get(key Hash, statusMask int, getMask int) (data []byte, entryType string, sources []string, status int, err error)
Get retrieves a value from the DHT store
func (*BuntHT) GetIdxMessage ¶
GetIdxMessage returns the messages that causes the change at a given index
func (*BuntHT) GetLinks ¶
func (ht *BuntHT) GetLinks(base Hash, tag string, statusMask int) (results []TaggedHash, err error)
GetLinks retrieves meta value associated with a base
func (*BuntHT) Iterate ¶
func (ht *BuntHT) Iterate(fn HashTableIterateFn)
func (*BuntHT) Mod ¶
Mod moves the given hash to the StatusModified status N.B. this functions assumes that the validity of this action has been confirmed
func (*BuntHT) Put ¶
func (ht *BuntHT) Put(m *Message, entryType string, key Hash, src peer.ID, value []byte, status int) (err error)
Put stores a value to the DHT store N.B. This call assumes that the value has already been validated
func (*BuntHT) PutLink ¶
PutLink associates a link with a stored hash N.B. this function assumes that the data associated has been properly retrieved and validated from the cource chain
type Capability ¶
type Capability struct { Token string // contains filtered or unexported fields }
func NewCapability ¶
func NewCapability(db *buntdb.DB, capability string, who interface{}) (c *Capability, err error)
NewCapability returns and registers a capability of a type, for a specific or anyone if who is nil
func (*Capability) Revoke ¶
func (c *Capability) Revoke(who interface{}) (err error)
Revoke unregisters the capability for a peer
func (*Capability) Validate ¶
func (c *Capability) Validate(who interface{}) (capability string, err error)
Validate checks to see if the token has been registered and returns the capability it represent
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[Hash]int // map header hashes to index number Emap map[Hash]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 ¶
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(now time.Time, entryType string, e Entry, privKey ic.PrivKey) (hash Hash, err error)
AddEntry creates a new header and adds it to a chain
func (*Chain) BundleStarted ¶
BundleStarted returns the index of the chain item before the bundle or 0 if no bundle is active
func (*Chain) CloseBundle ¶
CloseBundle closes a started bundle and if commit copies entries from the bundle onto the chain
func (*Chain) Dump ¶
Dump converts a chain to a textual dump of the headers and entries from a starting index
func (*Chain) GetEntryHeader ¶
GetEntryHeader returns the header of a given entry hash
func (*Chain) MarshalChain ¶
func (c *Chain) MarshalChain(writer io.Writer, flags int64, whitelistTypes []string, privateTypes []string) (err error)
MarshalChain serializes a chain data to a writer
func (*Chain) StartBundle ¶
StartBundle marks a bundle start point and returns an error if already started
type Change ¶
type Change struct { Type ChangeType Message string AsOf int }
Change represents a semantic change that needs to be reported
type CloserPeersResp ¶
type CloserPeersResp struct {
CloserPeers []PeerInfo // note this is not a pstore.PeerInfo which can't be serialized by gob.
}
type CommittingAction ¶
type CommittingAction interface { Name() string // Performs all validation logic, including sysValidation (must be called explicitly) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error) Receive(dht *DHT, msg *Message) (response interface{}, err error) CheckValidationRequest(def *EntryDef) (err error) EntryType() string // returns a GobEntry containing the action's entry in a serialized format Entry() Entry SetHeader(header *Header) GetHeader() (header *Header) Share(h *Holochain, def *EntryDef) (err error) }
CommittingAction provides an abstraction for grouping actions which carry Entry data
type Config ¶
type Config struct { DHTPort int EnableMDNS bool PeerModeAuthor bool PeerModeDHTNode bool EnableNATUPnP bool EnableWorldModel bool BootstrapServer string Loggers Loggers // contains filtered or unexported fields }
Config holds the non-DNA configuration for a holo-chain, from config file or environment variables
func (*Config) SetGossipInterval ¶
func (*Config) SetupLogging ¶
SetupLogging initializes loggers as configured by the config file and environment variables
type DHT ¶
type DHT struct {
// contains filtered or unexported fields
}
DHT struct holds the data necessary to run the distributed hash table
func (*DHT) AddGossiper ¶
AddGossiper adds a new gossiper to the gossiper store
func (*DHT) Del ¶
Del moves the given hash to the StatusDeleted status N.B. this functions assumes that the validity of this action has been confirmed
func (*DHT) DelLink ¶
DelLink removes a link and tag associated with a stored hash N.B. this function assumes that the action has been properly validated
func (*DHT) DeleteGossiper ¶
DeleteGossiper removes a gossiper from the database
func (*DHT) FindGossiper ¶
FindGossiper picks a random DHT node to gossip with
func (*DHT) Get ¶
func (dht *DHT) Get(key Hash, statusMask int, getMask int) (data []byte, entryType string, sources []string, status int, err error)
Get retrieves a value from the DHT store
func (*DHT) GetFingerprint ¶
GetFingerprint returns the index that of the message that made a change or -1 if we don't have it
func (*DHT) GetGossiper ¶
GetGossiper loads returns last known index of the gossiper, and adds them if not didn't exist before
func (*DHT) GetGossipers ¶
func (dht *DHT) GetGossipers() (gossipers []GossiperData, err error)
func (*DHT) GetIdxMessage ¶
GetIdxMessage returns the messages that causes the change at a given index
func (*DHT) GetLinks ¶
func (dht *DHT) GetLinks(base Hash, tag string, statusMask int) (results []TaggedHash, err error)
GetLinks retrieves meta value associated with a base
func (*DHT) HandleChangeRequests ¶
HandleChangeRequests waits on a channel for dht change requests
func (*DHT) HandleGossipPuts ¶
HandleGossipPuts waits on a channel for gossip changes
func (*DHT) HandleGossipWiths ¶
HandleGossipWiths waits on a channel for gossipWith requests
func (*DHT) HaveFingerprint ¶
HaveFingerprint returns true if we have seen the given fingerprint
func (*DHT) Iterate ¶
func (dht *DHT) Iterate(fn HashTableIterateFn)
func (*DHT) MakeHoldResp ¶
MakeHoldResp creates fill the HoldResp struct with a the holding status and signature
func (*DHT) MakeReceiptSignature ¶
MakeReceipt creates a signature of a message together with the receipt code
func (*DHT) Mod ¶
Mod moves the given hash to the StatusModified status N.B. this functions assumes that the validity of this action has been confirmed
func (*DHT) Put ¶
func (dht *DHT) Put(m *Message, entryType string, key Hash, src peer.ID, value []byte, status int) (err error)
Put stores a value to the DHT store N.B. This call assumes that the value has already been validated
func (*DHT) PutLink ¶
PutLink associates a link with a stored hash N.B. this function assumes that the data associated has been properly retrieved and validated from the cource chain
func (*DHT) Query ¶
func (dht *DHT) Query(key Hash, msgType MsgType, body interface{}) (response interface{}, err error)
Query sends DHT query messages recursively to peers until one is able to respond.
func (*DHT) SetupDHT ¶
SetupDHT prepares a DHT for use by putting the genesis entries that are added by GenChain
type DHTConfig ¶
type DHTConfig struct { // HashType : (string) Identifies hash type to be used for this application. Should be from the list of hash types from the multihash library HashType HashType //RedundancyFactor(integer) Establishes minimum online redundancy targets for data, and size of peer sets for sync gossip. A redundancy factor ZERO means no sharding (every node syncs all data with every other node). ONE means you are running this as a centralized application and gossip is turned OFF. For most applications we recommend neighborhoods no smaller than 8 for nearness or 32 for hashmask sharding. RedundancyFactor int }
Holds the dht configuration options
type DNA ¶
type DNA struct { Version int UUID uuid.UUID Name string Properties map[string]string PropertiesSchema string PropertiesSchemaFile string AgentIdentitySchema string // defines what must go in the Indentity field of a key/agent entry BasedOn Hash // references hash of another holochain that these schemas and code are derived from RequiresVersion int DHTConfig DHTConfig Progenitor Progenitor Zomes []Zome // contains filtered or unexported fields }
type DelEntry ¶
type DelEntry struct { Hash Hash Message string }
DelEntry struct holds the record of an entry's deletion
func DelEntryFromJSON ¶
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 Sharing string Schema string // contains filtered or unexported fields }
EntryDef struct holds an entry definition
func (*EntryDef) BuildJSONSchemaValidator ¶
BuildJSONSchemaValidator builds a validator in an EntryDef
func (*EntryDef) BuildJSONSchemaValidatorFromString ¶
func (*EntryDef) IsSysEntry ¶
IsSysEntry returns true if the entry type is system defined
func (*EntryDef) IsVirtualEntry ¶
IsVirtualEntry returns true if the entry type is virtual
type EntryDefFile ¶
type ErrorResponse ¶
func NewErrorResponse ¶
func NewErrorResponse(err error) (errResp ErrorResponse)
NewErrorResponse encodes standard errors for transmitting
func (ErrorResponse) DecodeResponseError ¶
func (errResp ErrorResponse) DecodeResponseError() (err error)
DecodeResponseError creates a go error object from the ErrorResponse data
type FindNodeReq ¶
type FindNodeReq struct {
H Hash
}
type FunctionDef ¶
FunctionDef holds the name and calling type of an DNA exposed function
func (*FunctionDef) ValidExposure ¶
func (f *FunctionDef) ValidExposure(context string) bool
ValidExposure verifies that the function can be called in the given context
type GetLinksOptions ¶
type GetLinksOptions struct { Load bool // indicates whether GetLinks should retrieve the entries of all links StatusMask int // mask of which status of links to return }
GetLinksOptions options to holochain level GetLinks functions
type GetOptions ¶
type GetOptions struct { StatusMask int // mask of which status of entries to return GetMask int // mask of what to include in the response Local bool // bool if get should happen from chain not DHT Bundle bool // bool if get should happen from bundle not DHT }
GetOptions options to holochain level Get functions
type GetResp ¶
type GetResp struct { Entry GobEntry EntryType string Sources []string FollowHash string // hash of new entry if the entry was modified and needs following }
GetResp holds the data of a get response
type GobEntry ¶
type GobEntry struct {
C interface{}
}
GobEntry is a structure for implementing Gob encoding of Entry content
type GossiperData ¶
type HashTable ¶
type HashTable interface { // Open initializes the table Open(options interface{}) (err error) // Close cleans up any resources used by the table Close() // Put stores a value to the DHT store Put(msg *Message, entryType string, key Hash, src peer.ID, value []byte, status int) (err error) // Del moves the given hash to the StatusDeleted status Del(msg *Message, key Hash) (err error) // Mod moves the given hash to the StatusModified status Mod(msg *Message, key Hash, newkey Hash) (err error) // Exists checks for the existence of the hash in the table Exists(key Hash, statusMask int) (err error) // Source returns the source node address of a given hash Source(key Hash) (id peer.ID, err error) // Get retrieves a value from the DHT store Get(key Hash, statusMask int, getMask int) (data []byte, entryType string, sources []string, status int, err error) // PutLink associates a link with a stored hash PutLink(m *Message, base string, link string, tag string) (err error) // DelLink removes a link and tag associated with a stored hash DelLink(m *Message, base string, link string, tag string) (err error) // GetLinks retrieves meta value associated with a base GetLinks(base Hash, tag string, statusMask int) (results []TaggedHash, err error) // GetIdx returns the current index of changes to the HashTable GetIdx() (idx int, err error) // GetIdxMessage returns the messages that causes the change at a given index GetIdxMessage(idx int) (msg Message, err error) // String converts the table into a human readable string String() string // JSON converts a DHT into a JSON string representation. JSON() (result string, err error) // Iterate call fn on all the hashes in the table Iterate(fn HashTableIterateFn) }
HashTable provides an abstraction for storing the necessary DHT data
type HashTableIterateFn ¶
type HashTableIterateFn func(hash Hash) (stop bool)
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 Change Hash }
Header holds chain links, type, timestamp and signature
type HoldReq ¶
type HoldReq struct { EntryHash Hash // hash of the entry responsible for the change RelatedHash Hash // hash of the related entry (link=base,del=deleted, mod=modified by) }
HoldReq holds the data of a change
type Holochain ¶
type Holochain struct { Config Config // contains filtered or unexported fields }
Holochain struct holds the full "DNA" of the holochain (all your app code for managing distributed data integrity)
func NewHolochain ¶
NewHolochain creates a new holochain structure with a randomly generated ID and default values
func (*Holochain) Activate ¶
Activate fires up the holochain node, starting node discovery and protocols
func (*Holochain) AddAgentEntry ¶
func (h *Holochain) AddAgentEntry(revocation Revocation) (headerHash, agentHash Hash, err error)
AddAgentEntry adds a new sys entry type setting the current agent data (identity and key)
func (*Holochain) AddBridgeAsCallee ¶
AddBridgeAsCallee registers a token for allowing bridged calls from some other app and calls bridgeGenesis in any zomes with bridge functions
func (*Holochain) AddBridgeAsCaller ¶
func (h *Holochain) AddBridgeAsCaller(bridgeZome string, calleeDNA Hash, calleeName string, token string, url string, appData string) (err error)
AddBridgeAsCaller associates a token with an application DNA hash and url for accessing it it also runs BridgeGenesis in the bridgeZome
func (*Holochain) AgentHash ¶
func (h *Holochain) AgentHash() (id Hash)
AgentHash returns the hash of the Agent entry
func (*Holochain) AgentTopHash ¶
func (h *Holochain) AgentTopHash() (id Hash)
AgentHash returns the hash of the Agent entry
func (*Holochain) BridgeCall ¶
func (h *Holochain) BridgeCall(zomeType string, function string, arguments interface{}, token string) (result interface{}, err error)
BridgeCall executes a function exposed through a bridge
func (*Holochain) BuildBridgeToCallee ¶
BuildBridgeToCallee connects h to a running app specified by BridgeApp that will be the Callee, i.e. the the BridgeCallee
func (*Holochain) BuildBridgeToCaller ¶
BuildBridgeToCaller connects h to a running app specified by BridgeApp that will be the Caller, i.e. the the BridgeCaller
func (*Holochain) Call ¶
func (h *Holochain) Call(zomeType string, function string, arguments interface{}, exposureContext string) (result interface{}, err error)
Call executes an exposed function
func (*Holochain) Close ¶
func (h *Holochain) Close()
Close releases the resources associated with a holochain
func (*Holochain) DNAHash ¶
func (h *Holochain) DNAHash() (id Hash)
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.
func (*Holochain) GetBridgeToken ¶
GetBridgeToken returns a token given the a hash
func (*Holochain) GetBridges ¶
GetBridges returns a list of the active bridges on the holochain
func (*Holochain) GetEntryDef ¶
GetEntryDef returns an EntryDef of the given name @TODO this makes the incorrect assumption that entry type strings are unique across zomes @see https://github.com/holochain/holochain-proto/issues/730
func (*Holochain) GetPrivateEntryDefs ¶
func (*Holochain) GetProperty ¶
GetProperty returns the value of a DNA property
func (*Holochain) GetValidationResponse ¶
func (h *Holochain) GetValidationResponse(a ValidatingAction, hash Hash) (resp ValidateResponse, err error)
GetValidationResponse check the validation request and builds the validation package based on the app's requirements
func (*Holochain) HandleAsyncSends ¶
HandleAsyncSends waits on a channel for asyncronous sends
func (*Holochain) HandlePeerFound ¶
implement peer found function for mdns discovery
func (*Holochain) HashSpec ¶
func (h *Holochain) HashSpec() HashSpec
HashSpec exposes the hashSpec structure
func (*Holochain) MakeRibosome ¶
MakeRibosome creates a Ribosome 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: 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) Query ¶
func (h *Holochain) Query(options *QueryOptions) (results []QueryResult, err error)
Query scans the local chain and returns a collection of results based on the options specified
func (*Holochain) RedundancyFactor ¶
RedundancyFactor returns the redundancy that was set in the DNA
func (*Holochain) Send ¶
func (h *Holochain) Send(basectx context.Context, proto int, to peer.ID, message *Message, timeout time.Duration) (response interface{}, err error)
Send builds a message and either delivers it locally or over the network via node.Send
func (*Holochain) SendAsync ¶
func (h *Holochain) SendAsync(proto int, to peer.ID, msg *Message, callback *Callback, timeout time.Duration) (err error)
SendAsync builds a message and either delivers it locally or over the network via node.Send but registers a function for asyncronous call back
func (*Holochain) StartBackgroundTasks ¶
func (h *Holochain) StartBackgroundTasks()
StartBackgroundTasks sets the various background processes in motion
func (*Holochain) TaskTicker ¶
TaskTicker creates a closure for a holochain task
func (*Holochain) ValidateAction ¶
func (h *Holochain) ValidateAction(a ValidatingAction, entryType string, pkg *Package, sources []peer.ID) (def *EntryDef, err error)
ValidateAction runs the different phases of validating an action
func (*Holochain) VerifySignature ¶
func (h *Holochain) VerifySignature(signature Signature, data string, pubKey ic.PubKey) (matches bool, err error)
VerifySignature uses the signature, data and the given public key to Verify the data was signed by holder of that key
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 BuildJSONSchemaValidatorFromFile ¶
func BuildJSONSchemaValidatorFromFile(path string) (validator *JSONSchemaValidator, err error)
func BuildJSONSchemaValidatorFromString ¶
func BuildJSONSchemaValidatorFromString(input string) (validator *JSONSchemaValidator, err error)
func (*JSONSchemaValidator) Validate ¶
func (v *JSONSchemaValidator) Validate(entry interface{}) (err error)
type JSRibosome ¶
type JSRibosome struct {
// contains filtered or unexported fields
}
JSRibosome holds data needed for the Javascript VM
func (*JSRibosome) BridgeGenesis ¶
func (jsr *JSRibosome) BridgeGenesis(side int, dnaHash Hash, data string) (err error)
BridgeGenesis runs the bridging genesis function this function gets called on both sides of the bridging
func (*JSRibosome) BundleCanceled ¶
func (jsr *JSRibosome) BundleCanceled(reason string) (response string, err error)
BundleCancel calls the app bundleCanceled function
func (*JSRibosome) Call ¶
func (jsr *JSRibosome) Call(fn *FunctionDef, params interface{}) (result interface{}, err error)
Call calls the zygo function that was registered with expose
func (*JSRibosome) ChainGenesis ¶
func (jsr *JSRibosome) ChainGenesis() (err error)
ChainGenesis runs the application genesis function this function gets called after the genesis entries are added to the chain
func (*JSRibosome) Receive ¶
func (jsr *JSRibosome) Receive(from string, msg string) (response string, err error)
Receive calls the app receive function for node-to-node messages
func (*JSRibosome) Run ¶
func (jsr *JSRibosome) Run(code string) (result interface{}, err error)
Run executes javascript code
func (*JSRibosome) RunAsyncSendResponse ¶
func (jsr *JSRibosome) RunAsyncSendResponse(response AppMsg, callback string, callbackID string) (result interface{}, err error)
func (*JSRibosome) Type ¶
func (jsr *JSRibosome) Type() string
Type returns the string value under which this ribosome is registered
func (*JSRibosome) ValidateAction ¶
func (jsr *JSRibosome) ValidateAction(action Action, def *EntryDef, pkg *ValidationPackage, sources []string) (err error)
ValidateAction builds the correct validation function based on the action an calls it
func (*JSRibosome) ValidatePackagingRequest ¶
func (jsr *JSRibosome) ValidatePackagingRequest(action ValidatingAction, def *EntryDef) (req PackagingReq, err error)
ValidatePackagingRequest calls the app for a validation packaging request for an action
type LibP2PAgent ¶
type LibP2PAgent struct {
// contains filtered or unexported fields
}
func (*LibP2PAgent) AgentEntry ¶
func (a *LibP2PAgent) AgentEntry(revocation Revocation) (entry AgentEntry, err error)
func (*LibP2PAgent) AgentType ¶
func (a *LibP2PAgent) AgentType() AgentType
func (*LibP2PAgent) EncodePubKey ¶
func (a *LibP2PAgent) EncodePubKey() (b58pk string, err error)
func (*LibP2PAgent) Identity ¶
func (a *LibP2PAgent) Identity() AgentIdentity
func (*LibP2PAgent) NodeID ¶
func (a *LibP2PAgent) NodeID() (nodeID peer.ID, nodeIDStr string, err error)
func (*LibP2PAgent) PrivKey ¶
func (a *LibP2PAgent) PrivKey() ic.PrivKey
func (*LibP2PAgent) PubKey ¶
func (a *LibP2PAgent) PubKey() ic.PubKey
func (*LibP2PAgent) SetIdentity ¶
func (a *LibP2PAgent) SetIdentity(id AgentIdentity)
type Link ¶
type Link struct { LinkAction string // StatusAction (either AddAction or DelAction) Base string // hash of entry (perhaps elsewhere) to which we are attaching the link Link string // hash of entry being linked to Tag string // tag }
Link structure for holding meta tagging of linking entry
type LinkQueryResp ¶
type LinkQueryResp struct {
Links []TaggedHash
}
LinkQueryResp holds response to getLinks query
type LinksEntry ¶
type LinksEntry struct {
Links []Link
}
LinksEntry holds one or more links
func LinksEntryFromJSON ¶
func LinksEntryFromJSON(j string) (entry LinksEntry, err error)
func (*LinksEntry) ToJSON ¶
func (ae *LinksEntry) ToJSON() (encodedEntry string, err error)
type ListAddReq ¶
type Logger ¶
type Logger struct { Name string Enabled bool Format string Prefix string PrefixColor *color.Color // contains filtered or unexported fields }
Logger holds logger configuration
type Loggers ¶
type Loggers struct { App Logger Debug Logger DHT Logger World 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
func (*Message) Decode ¶
Decode converts a message from gob format @TODO generalize for other message encoding formats
func (*Message) Encode ¶
Encode codes a message to gob format @TODO generalize for other message encoding formats
func (*Message) Fingerprint ¶
Fingerprint creates a hash of a message
type MigrateEntry ¶
MigrateEntry struct is the record of a chain opening or closing
func MigrateEntryFromJSON ¶
func MigrateEntryFromJSON(j string) (entry MigrateEntry, err error)
func (*MigrateEntry) Def ¶
func (e *MigrateEntry) Def() *EntryDef
@see https://github.com/holochain/holochain-proto/issues/731
func (*MigrateEntry) ToJSON ¶
func (e *MigrateEntry) ToJSON() (encodedEntry string, err error)
type ModAgentOptions ¶
type MsgType ¶
type MsgType int8
const ( ERROR_RESPONSE MsgType = iota OK_RESPONSE PUT_REQUEST DEL_REQUEST MOD_REQUEST GET_REQUEST LINK_REQUEST GETLINK_REQUEST DELETELINK_REQUEST GOSSIP_REQUEST VALIDATE_PUT_REQUEST VALIDATE_LINK_REQUEST VALIDATE_DEL_REQUEST VALIDATE_MOD_REQUEST APP_MESSAGE LISTADD_REQUEST FIND_NODE_REQUEST )
@TODO don't have order dependant constants https://github.com/holochain/holochain-proto/issues/713
type Node ¶
type Node struct { HashAddr peer.ID NetAddr ma.Multiaddr // contains filtered or unexported fields }
Node represents a node in the network
func NewNode ¶
func NewNode(listenAddr string, protoMux string, agent *LibP2PAgent, enableNATUPnP bool, log *Logger) (node *Node, err error)
NewNode creates a new node with given multiAddress listener string and identity
func (*Node) Distance ¶
Distance returns the nodes peer distance to another node for purposes of gossip
func (*Node) EnableMDNSDiscovery ¶
func (*Node) ExternalAddr ¶
func (*Node) FindLocal ¶
FindLocal looks for a peer with a given ID connected to this node and returns its peer info
func (*Node) FindPeer ¶
FindPeer searches for a peer with given ID. it is also an implementation the FindPeer() method of the RoutedHost interface in go-libp2p/p2p/host/routed and makes the Node object the "Router"
func (*Node) GetClosestPeers ¶
Kademlia 'node lookup' operation. Returns a channel of the K closest peers to the given key
func (*Node) InitBlockedList ¶
InitBlockedList sets up the blockedlist from a PeerList
func (*Node) NewMessage ¶
NewMessage creates a message from the node with a new current timestamp
func (*Node) Send ¶
func (node *Node) Send(ctx context.Context, proto int, addr peer.ID, m *Message) (response Message, err error)
Send delivers a message to a node via the given protocol
func (*Node) StartProtocol ¶
StartProtocol initiates listening for a protocol on the node
type NodeRecord ¶
NodeRecord stores the necessary information about other nodes in the world model
type Nucleus ¶
type Nucleus struct {
// contains filtered or unexported fields
}
Nucleus encapsulates Application parts: Ribosomes to run code in Zomes, plus application validation and direct message passing protocols
func NewNucleus ¶
NewNucleus creates a new Nucleus structure
func (*Nucleus) RunGenesis ¶
type Package ¶
type Package struct {
Chain []byte
}
Package holds app specified data needed for validation (wire package)
func MakePackage ¶
func MakePackage(h *Holochain, req PackagingReq) (pkg Package, err error)
MakePackage converts a package request into a package, loading chain data as necessary this is the package that gets sent over the wire. Chain DNA is omitted in this package because it can be added at the destination and the chain will still validate.
type PackagingReq ¶
type PackagingReq map[string]interface{}
PackagingReq holds a request from an app for data to be included in the validation response
type PeerInfo ¶
type PeerInfo struct { ID []byte // byte version peer.ID Addrs [][]byte // byte version of multiaddrs }
an encodable version of pstore.PeerInfo which gob doesn't like also libp2p encodes other stuff like connection type into this which we may have to do too.
type PeerList ¶
type PeerList struct { Type PeerListType Records []PeerRecord }
type PeerListType ¶
type PeerListType string
we also gossip about peers too, keeping lists of different peers e.g. blockedlist etc
type PeerRecord ¶
type Progenitor ¶
Progenitor holds data on the creator of the DNA
type Protocol ¶
type Protocol struct { ID protocol.ID Receiver ReceiverFn }
Protocol encapsulates data for our different protocols
type QueryConstrain ¶
type QueryOptions ¶
type QueryOptions struct { Return QueryReturn Constrain QueryConstrain Order QueryOrder Bundle bool }
type QueryOrder ¶
type QueryOrder struct {
Ascending bool
}
type QueryResult ¶
type QueryReturn ¶
type ReceiverFn ¶
type Revocation ¶
type Ribosome ¶
type Ribosome interface { Type() string ValidateAction(action Action, def *EntryDef, pkg *ValidationPackage, sources []string) (err error) ValidatePackagingRequest(action ValidatingAction, def *EntryDef) (req PackagingReq, err error) ChainGenesis() error BridgeGenesis(side int, dnaHash Hash, data string) error Receive(from string, msg string) (response string, err error) Call(fn *FunctionDef, params interface{}) (interface{}, error) Run(code string) (result interface{}, err error) RunAsyncSendResponse(response AppMsg, callback string, callbackID string) (result interface{}, err error) BundleCanceled(reason string) (response string, err error) }
Ribosome type abstracts the functions of code execution environments
func CreateRibosome ¶
CreateRibosome returns a new Ribosome of the given type
func NewJSRibosome ¶
NewJSRibosome factory function to build a javascript execution environment for a zome
type RoutingTable ¶
type RoutingTable struct { // kBuckets define all the fingers to other nodes. Buckets []*Bucket // notification functions PeerRemoved func(peer.ID) PeerAdded func(peer.ID) // contains filtered or unexported fields }
RoutingTable defines the routing table.
func NewRoutingTable ¶
func NewRoutingTable(bucketsize int, localID peer.ID, latency time.Duration, m pstore.Metrics) *RoutingTable
NewRoutingTable creates a new routing table with a given bucketsize, local ID, and latency tolerance.
func (*RoutingTable) Find ¶
func (rt *RoutingTable) Find(id peer.ID) peer.ID
Find a specific peer by ID or return nil
func (*RoutingTable) ListPeers ¶
func (rt *RoutingTable) ListPeers() []peer.ID
ListPeers takes a RoutingTable and returns a list of all peers from all buckets in the table. NOTE: This is potentially unsafe... use at your own risk
func (*RoutingTable) NearestPeer ¶
func (rt *RoutingTable) NearestPeer(hash Hash) peer.ID
NearestPeer returns a single peer that is nearest to the given Hash
func (*RoutingTable) NearestPeers ¶
func (rt *RoutingTable) NearestPeers(hash Hash, count int) []peer.ID
NearestPeers returns a list of the 'count' closest peers to the given ID
func (*RoutingTable) Print ¶
func (rt *RoutingTable) Print()
Print prints a descriptive statement about the provided RoutingTable
func (*RoutingTable) Remove ¶
func (rt *RoutingTable) Remove(p peer.ID)
Remove deletes a peer from the routing table. This is to be used when we are sure a node has disconnected completely.
func (*RoutingTable) Size ¶
func (rt *RoutingTable) Size() int
Size returns the total number of peers in the routing table
func (*RoutingTable) Update ¶
func (rt *RoutingTable) Update(p peer.ID)
Update adds or moves the given peer to the front of its respective bucket If a peer gets removed from a bucket, it is returned
type SchemaValidator ¶
type SchemaValidator interface {
Validate(interface{}) error
}
SchemaValidator interface for schema validation
type SelfRevocation ¶
type SelfRevocation struct { Data []byte // concatination of key length, two marshaled keys, and revocation properties OldSig []byte // signature of oldnew by old key NewSig []byte // signature by oldnew new key }
SelfRevocation holds the old key being revoked and the new key, other revocation data and the two cryptographic signatures of that data by the two keys to confirm the revocation
func NewSelfRevocation ¶
func NewSelfRevocation(old, new ic.PrivKey, payload []byte) (rP *SelfRevocation, err error)
func (*SelfRevocation) Marshal ¶
func (r *SelfRevocation) Marshal() (data string, err error)
func (*SelfRevocation) Unmarshal ¶
func (r *SelfRevocation) Unmarshal(data string) (err error)
func (*SelfRevocation) Verify ¶
func (r *SelfRevocation) Verify() (err error)
Verify confirms that a self-revocation is properly signed
type SelfRevocationWarrant ¶
type SelfRevocationWarrant struct {
Revocation SelfRevocation
}
SelfRevocationWarrant warrants that the first party revoked its own key in favor of the second
func NewSelfRevocationWarrant ¶
func NewSelfRevocationWarrant(revocation *SelfRevocation) (wP *SelfRevocationWarrant, err error)
func (*SelfRevocationWarrant) Decode ¶
func (w *SelfRevocationWarrant) Decode(data []byte) (err error)
func (*SelfRevocationWarrant) Encode ¶
func (w *SelfRevocationWarrant) Encode() (data []byte, err error)
func (*SelfRevocationWarrant) Parties ¶
func (w *SelfRevocationWarrant) Parties() (parties []Hash, err error)
func (*SelfRevocationWarrant) Property ¶
func (w *SelfRevocationWarrant) Property(key string) (value interface{}, err error)
func (*SelfRevocationWarrant) Type ¶
func (w *SelfRevocationWarrant) Type() int
func (*SelfRevocationWarrant) Verify ¶
func (w *SelfRevocationWarrant) Verify(h *Holochain) (err error)
type SendOptions ¶
type Service ¶
type Service struct { Settings ServiceConfig DefaultAgent Agent Path string }
A Service is a 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 SetupTestService ¶
func (*Service) Clone ¶
func (s *Service) Clone(srcPath string, root string, agent Agent, new bool, initDB bool) (hP *Holochain, err error)
Clone copies DNA files from a source directory bool new indicates if this clone should create a new DNA (when true) or act as a Join
func (*Service) ConfiguredChains ¶
ConfiguredChains returns a list of the configured chains for the given service
func (*Service) InitAppDir ¶
func (*Service) IsConfigured ¶
IsConfigured checks a directory for correctly set up holochain configuration file
func (*Service) ListChains ¶
List chains produces a textual representation of the chains in the .holochain directory
func (*Service) MakeAppPackage ¶
MakeAppPackage creates a package blob from a given holochain
func (*Service) MakeTestingApp ¶
func (s *Service) MakeTestingApp(root string, encodingFormat string, initDB bool, newUUID bool, agent Agent) (h *Holochain, err error)
MakeTestingApp generates a holochain used for testing purposes
func (*Service) SaveFromAppPackage ¶
func (service *Service) SaveFromAppPackage(reader io.Reader, path string, name string, agent Agent, decodingFormat string, encodingFormat string, newUUID bool) (appPackage *AppPackage, err error)
SaveFromAppPackage writes out a holochain application based on appPackage file to path
type ServiceConfig ¶
type ServiceConfig struct { DefaultPeerModeAuthor bool DefaultPeerModeDHTNode bool DefaultBootstrapServer string DefaultEnableMDNS bool DefaultEnableNATUPnP bool }
ServiceConfig holds the service settings
func (*ServiceConfig) Validate ¶
func (c *ServiceConfig) Validate() (err error)
Validate validates settings values
type Signature ¶
type Signature struct {
S []byte
}
func SignatureFromB58String ¶
SignatureFromB58String encodes a signature as a b58string
type TaggedHash ¶
type TaggedHash struct { H string // the hash of the link; gets filled by dht base node when answering get link request E string // the value of link, gets filled if options set Load to true EntryType string // the entry type of the link, gets filled if options set Load to true T string // the tag of the link, gets filled only if a tag wasn't specified and all tags are being returns Source string // the statuses on the link, gets filled if options set Load to true }
TaggedHash holds associated entries for the LinkQueryResponse
type TestConfig ¶
type TestConfig struct { GossipInterval int // interval in milliseconds between gossips Duration int // if non-zero number of seconds to keep all nodes alive Clone []CloneSpec }
TestConfig holds the configuration options for a test
func LoadTestConfig ¶
func LoadTestConfig(dir string) (config *TestConfig, err error)
LoadTestConfig unmarshals test json data
type TestData ¶
type TestData struct { Convey string // a human readable description of the tests intent Zome string // the zome in which to find the function FnName string // the function to call Input interface{} // the function's input Output interface{} // the expected output to match against (full match) Err interface{} // the expected error to match against ErrMsg string // the expected error message to match against Regexp string // the expected out to match again (regular expression) Time time.Duration // offset in milliseconds from the start of the test at which to run this test. Wait time.Duration // time in milliseconds to wait before running this test from when the previous ran Exposure string // the exposure context for the test call (defaults to ZOME_EXPOSURE) Raw bool // set to true if we should ignore fnName and just call input as raw code in the zome, useful for testing helper functions and validation functions Repeat int // number of times to repeat this test, useful for scenario testing Benchmark bool // activate benchmarking for this test }
TestData holds a test entry for a chain
type TestFixtures ¶
type TestFixtures struct {
Agents []AgentFixture
}
TestFixtures defines data needed to run tests
type TestSet ¶
type TestSet struct { Tests []TestData Identity string Fixtures TestFixtures Benchmark bool // activate benchmarking for all tests }
TestSet holds a set of tests plus configuration and fixture data for those tests
type ValidateQuery ¶
type ValidateQuery struct {
H Hash
}
ValidateQuery holds the data from a validation query on the Source protocol
type ValidateResponse ¶
ValidateResponse holds the response to committing validates (PUT/MOD/DEL)
type ValidatingAction ¶
type ValidatingAction interface { Name() string SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error) Receive(dht *DHT, msg *Message) (response interface{}, err error) CheckValidationRequest(def *EntryDef) (err error) }
ValidatingAction provides an abstraction for grouping all the actions that participate in validation loop
type ValidationPackage ¶
type ValidationPackage struct {
Chain *Chain
}
ValidationPackage holds app specified data needed for validation. This version holds the package with any chain data un-marshaled after validation for passing into the app for app level validation
func MakeValidationPackage ¶
func MakeValidationPackage(h *Holochain, pkg *Package) (vpkg *ValidationPackage, err error)
MakeValidationPackage converts a received Package into a ValidationPackage and validates any chain data that was included
type Warrant ¶
type Warrant interface { // Int returns the warrant type Type() int // Parties returns the hashes of the public keys of the signers of the warrant Parties() ([]Hash, error) // Verify confirms that the content of a warrant is valid and has been signed by the // the parties in it. Requires a Holochain object for context, returns nil if it // verfies or an error Verify(h *Holochain) error // Property returns a value of a property attested to by the warrant // returns a WarrantPropertyNotFoundErr if the warrant doesn't have that property Property(key string) (value interface{}, err error) // Encode marshals the warrant into bytes for sending over the wire Encode() (data []byte, err error) // Decode unmarshals a warrant from bytes Decode(data []byte) (err error) }
Warrant abstracts the notion of a multi-party cryptographically verifiable signed claim the meaning of the warrant is understood by the warrant name an/or by properties contained in it
type World ¶
type World struct {
// contains filtered or unexported fields
}
World holds the data of a nodes' world model
func (*World) GetNodeRecord ¶
func (world *World) GetNodeRecord(ID peer.ID) (record *NodeRecord)
GetNodeRecord returns the peer's node record NOTE: do not modify the contents of the returned record! not thread safe
func (*World) Responsible ¶
Responsible returns a list of all the entries I'm responsible for holding
func (*World) SetNodeHolding ¶
SetNodeHolding marks a node as holding a particular hash
type Zome ¶
type Zome struct { Name string Description string Code string Entries []EntryDef RibosomeType string Functions []FunctionDef BridgeFuncs []string // functions in zome that can be bridged to by callerApp // BridgeCallee Hash // dna Hash of provider App that this zome will call Config map[string]interface{} }
Zome struct encapsulates logically related code, from a "chromosome"
func (*Zome) CodeFileName ¶
func (*Zome) GetEntryDef ¶
GetEntryDef returns the entry def structure
func (*Zome) GetFunctionDef ¶
func (zome *Zome) GetFunctionDef(fnName string) (fn *FunctionDef, err error)
GetFunctionDef returns the exposed function spec for the given zome and function
func (*Zome) GetPrivateEntryDefs ¶
type ZomeFile ¶
type ZomeFile struct { Name string Description string CodeFile string RibosomeType string BridgeFuncs []string // functions in zome that can be bridged to by fromApp Config map[string]interface{} Entries []EntryDefFile Functions []FunctionDef }
type ZygoRibosome ¶
type ZygoRibosome struct {
// contains filtered or unexported fields
}
ZygoRibosome holds data needed for the Zygo VM
func (*ZygoRibosome) BridgeGenesis ¶
func (z *ZygoRibosome) BridgeGenesis(side int, dnaHash Hash, data string) (err error)
BridgeGenesis runs the bridging genesis function this function gets called on both sides of the bridging
func (*ZygoRibosome) BundleCanceled ¶
func (z *ZygoRibosome) BundleCanceled(reason string) (response string, err error)
BundleCancel calls the app bundleCanceled function
func (*ZygoRibosome) Call ¶
func (z *ZygoRibosome) Call(fn *FunctionDef, params interface{}) (result interface{}, err error)
Call calls the zygo function that was registered with expose
func (*ZygoRibosome) ChainGenesis ¶
func (z *ZygoRibosome) ChainGenesis() (err error)
ChainGenesis runs the application genesis function this function gets called after the genesis entries are added to the chain
func (*ZygoRibosome) Receive ¶
func (z *ZygoRibosome) Receive(from string, msg string) (response string, err error)
Receive calls the app receive function for node-to-node messages
func (*ZygoRibosome) Run ¶
func (z *ZygoRibosome) Run(code string) (result interface{}, err error)
Run executes zygo code
func (*ZygoRibosome) RunAsyncSendResponse ¶
func (z *ZygoRibosome) RunAsyncSendResponse(response AppMsg, callback string, callbackID string) (result interface{}, err error)
func (*ZygoRibosome) Type ¶
func (z *ZygoRibosome) Type() string
Type returns the string value under which this ribosome is registered
func (*ZygoRibosome) ValidateAction ¶
func (z *ZygoRibosome) ValidateAction(action Action, def *EntryDef, pkg *ValidationPackage, sources []string) (err error)
ValidateAction builds the correct validation function based on the action an calls it
func (*ZygoRibosome) ValidatePackagingRequest ¶
func (z *ZygoRibosome) ValidatePackagingRequest(action ValidatingAction, def *EntryDef) (req PackagingReq, err error)
ValidatePackagingRequest calls the app for a validation packaging request for an action
Source Files ¶
- action.go
- action_addlist.go
- action_bridge.go
- action_bundleclose.go
- action_bundlestart.go
- action_call.go
- action_commit.go
- action_debug.go
- action_delete.go
- action_get.go
- action_getbridges.go
- action_getlinks.go
- action_link.go
- action_makehash.go
- action_migrate.go
- action_property.go
- action_put.go
- action_query.go
- action_send.go
- action_sign.go
- action_update.go
- action_updateagent.go
- agent.go
- app_package.go
- bridge.go
- bs.go
- buntdbht.go
- capabilities.go
- chain.go
- change.go
- dht.go
- doc.go
- entry.go
- entry_agent.go
- entry_del.go
- entry_dna.go
- entry_headers.go
- entry_key.go
- entry_links.go
- entry_migrate.go
- gossip.go
- header.go
- holochain.go
- ht.go
- jsribosome.go
- kad_bucket.go
- kad_lookup.go
- kad_query.go
- kad_rpc.go
- kad_table.go
- log.go
- node.go
- node_test_util.go
- notifi.go
- nucleus.go
- revocation.go
- ribosome.go
- service.go
- test.go
- test_data.go
- utils.go
- validate.go
- warrant.go
- world.go
- zome.go
- zygosome.go