Documentation ¶
Overview ¶
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 ----------------------------------------------------------------------------------------
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/metacurrency/holochain/tree/master/cmd/hc
For information not found here see the wiki:
https://github.com/metacurrency/holochain/wiki
or the repo:
https://github.com/metacurrency/holochain
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 DirExists(pathParts ...string) bool
- func Encode(writer io.Writer, format string, data interface{}) (err error)
- func EncodingFormat(file string) (f string)
- func FileExists(pathParts ...string) bool
- 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 Info(m string)
- func Infof(m string, args ...interface{})
- func InitializeHolochain()
- func IsInitialized(root string) 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 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 Panix(on string)
- func PrepareTestChain(n string) (d string, s *Service, h *Holochain)
- 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 SetupTestChain(n string) (d string, s *Service, h *Holochain)
- func SetupTestDir() string
- func ShouldLog(log *Logger, message string, fn func())
- 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 WriteFile(data []byte, pathParts ...string) error
- type Action
- type ActionBridge
- type ActionCall
- type ActionCommit
- func (a *ActionCommit) Args() []Arg
- func (a *ActionCommit) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionCommit) Do(h *Holochain) (response interface{}, err error)
- func (a *ActionCommit) Entry() Entry
- func (a *ActionCommit) EntryType() string
- func (a *ActionCommit) Name() string
- func (a *ActionCommit) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error)
- func (a *ActionCommit) SetHeader(header *Header)
- func (a *ActionCommit) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionDebug
- type ActionDel
- func (a *ActionDel) Args() []Arg
- func (a *ActionDel) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionDel) Do(h *Holochain) (response interface{}, err error)
- func (a *ActionDel) Entry() Entry
- func (a *ActionDel) EntryType() string
- func (a *ActionDel) Name() string
- func (a *ActionDel) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error)
- func (a *ActionDel) SetHeader(header *Header)
- func (a *ActionDel) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionGet
- func (a *ActionGet) Args() []Arg
- func (a *ActionGet) Do(h *Holochain) (response interface{}, err error)
- func (a *ActionGet) Name() string
- func (a *ActionGet) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error)
- func (a *ActionGet) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionGetBridges
- type ActionGetLinks
- func (a *ActionGetLinks) Args() []Arg
- func (a *ActionGetLinks) Do(h *Holochain) (response interface{}, err error)
- func (a *ActionGetLinks) Name() string
- func (a *ActionGetLinks) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error)
- func (a *ActionGetLinks) SysValidation(h *Holochain, d *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionLink
- func (a *ActionLink) Args() []Arg
- func (a *ActionLink) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionLink) Do(h *Holochain) (response interface{}, err error)
- func (a *ActionLink) Name() string
- func (a *ActionLink) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error)
- func (a *ActionLink) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionListAdd
- type ActionMakeHash
- type ActionMod
- func (a *ActionMod) Args() []Arg
- func (a *ActionMod) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionMod) Do(h *Holochain) (response interface{}, err error)
- func (a *ActionMod) Entry() Entry
- func (a *ActionMod) EntryType() string
- func (a *ActionMod) Name() string
- func (a *ActionMod) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error)
- func (a *ActionMod) SetHeader(header *Header)
- func (a *ActionMod) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionModAgent
- type ActionProperty
- type ActionPut
- func (a *ActionPut) Args() []Arg
- func (a *ActionPut) CheckValidationRequest(def *EntryDef) (err error)
- func (a *ActionPut) Do(h *Holochain) (response interface{}, err error)
- func (a *ActionPut) Name() string
- func (a *ActionPut) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error)
- func (a *ActionPut) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
- type ActionQuery
- type ActionSend
- type ActionSign
- type ActionVerifySignature
- 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 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) Close()
- 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) 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) 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 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) DeleteGossiper(id peer.ID) (err error)
- func (dht *DHT) DumpIdx(idx int) (str string, err error)
- func (dht *DHT) FindGossiper() (g peer.ID, 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) GetIdx() (idx int, err error)
- func (dht *DHT) GetIdxMessage(idx int) (msg Message, err error)
- func (dht *DHT) GetPuts(since int) (puts []Put, 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) Query(key Hash, msgType MsgType, body interface{}) (response interface{}, err error)
- func (dht *DHT) SetupDHT() (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 DelReq
- 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 Header
- 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(toDNA Hash, token string, url string, appData 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) BuildBridge(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) Prepare() (err error)
- func (h *Holochain) PrepareHashType() (err error)
- func (h *Holochain) Query(options *QueryOptions) (results []QueryResult, err error)
- 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(doc []byte) (sig []byte, 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 []byte, data string, pubKey ic.PubKey) (matches bool, err error)
- func (h *Holochain) Walk(fn WalkerFn, entriesToo bool) (err error)
- 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) 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) 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 LinkEvent
- type LinkQuery
- type LinkQueryResp
- type LinkReq
- type LinksEntry
- type ListAddReq
- type Logger
- type Loggers
- type Message
- type Meta
- type ModAgentOptions
- type ModReq
- 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 Nucleus
- type Package
- type PackagingReq
- type PeerInfo
- type PeerList
- type PeerListType
- type PeerRecord
- type Progenitor
- type Protocol
- type Put
- type PutReq
- 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 StatusChange
- type TaggedHash
- type TestConfig
- type TestData
- type TestFixtures
- type TestSet
- type ValidateQuery
- type ValidateResponse
- type ValidatingAction
- type ValidationPackage
- type WalkerFn
- type Warrant
- 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) 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 ( ChainMarshalFlagsNone = 0x00 ChainMarshalFlagsNoHeaders = 0x01 ChainMarshalFlagsNoEntries = 0x02 ChainMarshalFlagsOmitDNA = 0x04 ChainMarshalFlagsNoPrivate = 0x08 ChainMarshalPrivateEntryRedacted = "%%PRIVATE ENTRY REDACTED%%" )
const ( AddAction = "" ModAction = "m" DelAction = "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 ( GossipWithQueueSize = 10 GossipPutQueueSize = 1000 )
const ( SysEntryTypePrefix = "%" VirtualEntryTypePrefix = "%%" DNAEntryType = SysEntryTypePrefix + "dna" AgentEntryType = SysEntryTypePrefix + "agent" KeyEntryType = VirtualEntryTypePrefix + "key" // virtual entry type, not actually on the chain DataFormatLinks = "links" DataFormatJSON = "json" DataFormatString = "string" DataFormatRawJS = "js" DataFormatRawZygo = "zygo" DataFormatSysDNA = "_DNA" DataFormatSysAgent = "_agent" DataFormatSysKey = "_key" Public = "public" Partial = "partial" Private = "private" )
const ( // Version is the numeric version number of the holochain library Version int = 18 // VersionStr is the textual version number of the holochain library VersionStr string = "18" // DefaultSendTimeout a time.Duration to wait by default for send to complete DefaultSendTimeout = 3000 * time.Millisecond )
const ( ActionProtocol = iota ValidateProtocol GossipProtocol KademliaProtocol )
const ( PeerTTL = time.Minute * 10 DefaultRoutingRefreshInterval = time.Minute DefaultGossipInterval = time.Second * 2 )
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" BridgeFrom = 0 BridgeTo = 1 BridgeFromStr = "0" BridgeToStr = "1" )
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" DefaultPort = 6283 DefaultBootstrapServer = "bootstrap.holochain.net:10000" DefaultBootstrapServerEnvVar = "HC_DEFAULT_BOOTSTRAPSERVER" DefaultEnableMDNSEnvVar = "HC_DEFAULT_ENABLEMDNS" DefaultEnableNATUPnPEnvVar = "HC_DEFAULT_ENABLENATUPNP" 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 (
DefaultRetryInterval = time.Millisecond * 500
)
const (
GossipBackPutDelay = 100 * time.Millisecond
)
const ( JSLibrary = `var HC={Version:` + `"` + VersionStr + "\"" + `,Status:{Live:` + StatusLiveVal + `,Rejected:` + StatusRejectedVal + `,Deleted:` + StatusDeletedVal + `,Modified:` + StatusModifiedVal + `,Any:` + StatusAnyVal + "}" + `,GetMask:{Default:` + GetMaskDefaultStr + `,Entry:` + GetMaskEntryStr + `,EntryType:` + GetMaskEntryTypeStr + `,Sources:` + GetMaskSourcesStr + `,All:` + GetMaskAllStr + "}" + `,LinkAction:{Add:"` + AddAction + `",Del:"` + DelAction + `"}` + `,PkgReq:{Chain:"` + PkgReqChain + `"` + `,ChainOpt:{None:` + PkgReqChainOptNoneStr + `,Headers:` + PkgReqChainOptHeadersStr + `,Entries:` + PkgReqChainOptEntriesStr + `,Full:` + PkgReqChainOptFullStr + "}" + "}" + `,Bridge:{From:` + BridgeFromStr + `,To:` + BridgeToStr + "}" + `};` )
const (
JSRibosomeType = "js"
)
const (
LibP2P = iota
)
const (
MaxRetries = 10
)
const (
SelfRevocationType = iota
)
const (
TestingAppDecodingFormat = "json"
)
const ( ZygoLibrary = `(def HC_Version "` + VersionStr + `")` + `(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_From ` + BridgeFromStr + ")" + `(def HC_Bridge_To ` + BridgeToStr + ")" + `(def HC_LinkAction_Add "` + AddAction + "\")" + `(def HC_LinkAction_Del "` + DelAction + "\")" + `(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 + "\")" )
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: DataFormatSysAgent}
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\": [\"body\", \"timestamp\"]\n}", "_": "cr" } ], # 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. "_": "c:sampleEntry" }, { "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. "_": "r:sampleEntry" }, { "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": "'use strict';\n\n// -----------------------------------------------------------------\n// This stub Zome code file was auto-generated\n// -----------------------------------------------------------------\n\n/**\n * Called only when your source chain is generated\n * @return {boolean} success\n */\nfunction genesis() {\n // any genesis code here\n return true;\n}\n\n// -----------------------------------------------------------------\n// validation functions for every DHT entry change\n// -----------------------------------------------------------------\n\n/**\n * Called to validate any changes to the DHT\n * @param {string} entryName - the name of entry being modified\n * @param {*} entry - the entry data to be set\n * @param {?} header - ?\n * @param {?} pkg - ?\n * @param {?} sources - ?\n * @return {boolean} is valid?\n */\nfunction validateCommit (entryName, entry, header, pkg, sources) {\n switch (entryName) {\n case \"sampleEntry\":\n // validation code here\n return false;\n default:\n // invalid entry name!!\n return false;\n }\n}\n\n/**\n * Called to validate any changes to the DHT\n * @param {string} entryName - the name of entry being modified\n * @param {*}entry - the entry data to be set\n * @param {?} header - ?\n * @param {?} pkg - ?\n * @param {?} sources - ?\n * @return {boolean} is valid?\n */\nfunction validatePut (entryName, entry, header, pkg, sources) {\n switch (entryName) {\n case \"sampleEntry\":\n // validation code here\n return false;\ndefault:\n // invalid entry name!!\n return false;\n }\n}\n\n/**\n * Called to validate any changes to the DHT\n * @param {string} entryName - the name of entry being modified\n * @param {*} entry- the entry data to be set\n * @param {?} header - ?\n * @param {*} replaces - the old entry data\n * @param {?} pkg - ?\n * @param {?} sources - ?\n * @return {boolean} is valid?\n */\nfunction validateMod (entryName, entry, header, replaces, pkg, sources) {\n switch (entryName) {\n case \"sampleEntry\":\n // validation code here\n return false;\n default:\n // invalid entry name!!\n return false;\n }\n}\n\n/**\n * Called to validate any changes to the DHT\n * @param {string} entryName - the name of entry being modified\n * @param {string} hash - the hash of the entry to remove\n * @param {?} pkg - ?\n * @param {?} sources - ?\n * @return {boolean} is valid?\n */\nfunction validateDel (entryName,hash, pkg, sources) {\n switch (entryName) {\n case \"sampleEntry\":\n // validation code here\nreturn false;\n default:\n // invalid entry name!!\n return false;\n }\n}\n\n/**\n * Called to get the data needed to validate\n * @param {string} entryName - the name of entry to validate\n * @return {*} the data required for validation\n */\nfunction validatePutPkg (entryName) {\n return null;\n}\n\n/**\n * Called to get the data needed to validate\n * @param {string} entryName - the name of entry to validate\n * @return {*} the data required for validation\n */\nfunction validateModPkg (entryName) {\n return null;\n}\n\n/**\n * Called to get the data needed to validate\n * @param {string} entryName - the name of entry to validate\n * @return {*} the data required for validation\n */\nfunction validateDelPkg (entryName) {\n return null;\n}" } ]}, "TestSets":[{ "Name":"sample", "TestSet":{"Tests":[{"Convey":"We can create a new sampleEntry","FnName": "sampleEntryCreate","Input": {"body": "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 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 DevDNAResolveMap map[string]string
var EnableAllLoggersEnv string = "HC_ENABLE_ALL_LOGS"
var ErrBlockedListed = errors.New("node blockedlisted")
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 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 ErrNilEntryInvalid error = errors.New("nil entry invalid")
var ErrNoSuchIdx error = errors.New("no such change index")
var ErrNotValidForAgentType error = errors.New("Invalid action for Agent type")
var ErrNotValidForDNAType error = errors.New("Invalid action for DNA 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 IsDevMode bool = false
IsDevMode is used to enable certain functionality when developing holochains, for example, in dev mode, you can put the name of an app in the BridgeTo of the DNA and it will get resolved to DNA hash of the app in the DevDNAResolveMap[name] global variable.
var KValue int = 10
var KeyEntryDef = &EntryDef{Name: KeyEntryType, DataFormat: DataFormatSysKey}
var NonCallableAction error = errors.New("Not a callable action")
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("Validation Failed")
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 EncodingFormat ¶
EncodingFormat returns the files format if supported otherwise ""
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 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 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 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 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 RoutingRefreshTask ¶
func RoutingRefreshTask(h *Holochain)
RoutingRefreshTask fills the routing table by searching for a random node
func RunValidationPhase ¶
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
Types ¶
type Action ¶
type Action interface { Name() string Do(h *Holochain) (response interface{}, err error) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error) Args() []Arg }
Action provides an abstraction for grouping all the aspects of a nucleus function, i.e. the initiating actions, receiving them, validation, ribosome generation etc
func MakeActionFromMessage ¶
MakeActionFromMessage generates an action from an action protocol messsage
type ActionBridge ¶
type ActionBridge struct {
// contains filtered or unexported fields
}
func NewBridgeAction ¶
func NewBridgeAction(zome string, function string, args interface{}) *ActionBridge
func (*ActionBridge) Args ¶
func (a *ActionBridge) Args() []Arg
func (*ActionBridge) Do ¶
func (a *ActionBridge) Do(h *Holochain) (response interface{}, err error)
func (*ActionBridge) Name ¶
func (a *ActionBridge) Name() string
type ActionCall ¶
type ActionCall struct {
// contains filtered or unexported fields
}
func NewCallAction ¶
func NewCallAction(zome string, function string, args interface{}) *ActionCall
func (*ActionCall) Args ¶
func (a *ActionCall) Args() []Arg
func (*ActionCall) Do ¶
func (a *ActionCall) Do(h *Holochain) (response interface{}, err error)
func (*ActionCall) Name ¶
func (a *ActionCall) Name() string
type ActionCommit ¶
type ActionCommit struct {
// contains filtered or unexported fields
}
func NewCommitAction ¶
func NewCommitAction(entryType string, entry Entry) *ActionCommit
func (*ActionCommit) Args ¶
func (a *ActionCommit) Args() []Arg
func (*ActionCommit) CheckValidationRequest ¶
func (a *ActionCommit) CheckValidationRequest(def *EntryDef) (err error)
func (*ActionCommit) Do ¶
func (a *ActionCommit) Do(h *Holochain) (response interface{}, err error)
func (*ActionCommit) Entry ¶
func (a *ActionCommit) Entry() Entry
func (*ActionCommit) EntryType ¶
func (a *ActionCommit) EntryType() string
func (*ActionCommit) Name ¶
func (a *ActionCommit) Name() string
func (*ActionCommit) Receive ¶
func (a *ActionCommit) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error)
func (*ActionCommit) SetHeader ¶
func (a *ActionCommit) SetHeader(header *Header)
func (*ActionCommit) SysValidation ¶
type ActionDebug ¶
type ActionDebug struct {
// contains filtered or unexported fields
}
func NewDebugAction ¶
func NewDebugAction(msg string) *ActionDebug
func (*ActionDebug) Args ¶
func (a *ActionDebug) Args() []Arg
func (*ActionDebug) Do ¶
func (a *ActionDebug) Do(h *Holochain) (response interface{}, err error)
func (*ActionDebug) Name ¶
func (a *ActionDebug) Name() string
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
}
------------------------------------------------------------ Get
func NewGetAction ¶
func NewGetAction(req GetReq, options *GetOptions) *ActionGet
type ActionGetBridges ¶
type ActionGetBridges struct { }
func NewGetBridgesAction ¶
func NewGetBridgesAction(doc []byte) *ActionGetBridges
func (*ActionGetBridges) Args ¶
func (a *ActionGetBridges) Args() []Arg
func (*ActionGetBridges) Do ¶
func (a *ActionGetBridges) Do(h *Holochain) (response interface{}, err error)
func (*ActionGetBridges) Name ¶
func (a *ActionGetBridges) Name() string
type ActionGetLinks ¶
type ActionGetLinks struct {
// contains filtered or unexported fields
}
func NewGetLinksAction ¶
func NewGetLinksAction(linkQuery *LinkQuery, options *GetLinksOptions) *ActionGetLinks
func (*ActionGetLinks) Args ¶
func (a *ActionGetLinks) Args() []Arg
func (*ActionGetLinks) Do ¶
func (a *ActionGetLinks) Do(h *Holochain) (response interface{}, err error)
func (*ActionGetLinks) Name ¶
func (a *ActionGetLinks) Name() string
func (*ActionGetLinks) Receive ¶
func (a *ActionGetLinks) Receive(dht *DHT, msg *Message, retries int) (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) Args ¶
func (a *ActionLink) Args() []Arg
func (*ActionLink) CheckValidationRequest ¶
func (a *ActionLink) CheckValidationRequest(def *EntryDef) (err error)
func (*ActionLink) Do ¶
func (a *ActionLink) Do(h *Holochain) (response interface{}, err error)
func (*ActionLink) Name ¶
func (a *ActionLink) Name() string
func (*ActionLink) Receive ¶
func (a *ActionLink) Receive(dht *DHT, msg *Message, retries int) (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) Args ¶
func (a *ActionListAdd) Args() []Arg
func (*ActionListAdd) Do ¶
func (a *ActionListAdd) Do(h *Holochain) (response interface{}, err error)
func (*ActionListAdd) Name ¶
func (a *ActionListAdd) Name() string
type ActionMakeHash ¶
type ActionMakeHash struct {
// contains filtered or unexported fields
}
func NewMakeHashAction ¶
func NewMakeHashAction(entry Entry) *ActionMakeHash
func (*ActionMakeHash) Args ¶
func (a *ActionMakeHash) Args() []Arg
func (*ActionMakeHash) Do ¶
func (a *ActionMakeHash) Do(h *Holochain) (response interface{}, err error)
func (*ActionMakeHash) Name ¶
func (a *ActionMakeHash) Name() string
type ActionMod ¶
type ActionMod struct {
// contains filtered or unexported fields
}
func NewModAction ¶
func (*ActionMod) CheckValidationRequest ¶
type ActionModAgent ¶
type ActionModAgent struct { Identity AgentIdentity Revocation string }
func NewModAgentAction ¶
func NewModAgentAction(identity AgentIdentity) *ActionModAgent
func (*ActionModAgent) Args ¶
func (a *ActionModAgent) Args() []Arg
func (*ActionModAgent) Do ¶
func (a *ActionModAgent) Do(h *Holochain) (response interface{}, err error)
func (*ActionModAgent) Name ¶
func (a *ActionModAgent) Name() string
type ActionProperty ¶
type ActionProperty struct {
// contains filtered or unexported fields
}
func NewPropertyAction ¶
func NewPropertyAction(prop string) *ActionProperty
func (*ActionProperty) Args ¶
func (a *ActionProperty) Args() []Arg
func (*ActionProperty) Do ¶
func (a *ActionProperty) Do(h *Holochain) (response interface{}, err error)
func (*ActionProperty) Name ¶
func (a *ActionProperty) Name() string
type ActionPut ¶
type ActionPut struct {
// contains filtered or unexported fields
}
func (*ActionPut) CheckValidationRequest ¶
type ActionQuery ¶
type ActionQuery struct {
// contains filtered or unexported fields
}
func NewQueryAction ¶
func NewQueryAction(options *QueryOptions) *ActionQuery
func (*ActionQuery) Args ¶
func (a *ActionQuery) Args() []Arg
func (*ActionQuery) Do ¶
func (a *ActionQuery) Do(h *Holochain) (response interface{}, err error)
func (*ActionQuery) Name ¶
func (a *ActionQuery) Name() string
type ActionSend ¶
type ActionSend struct {
// contains filtered or unexported fields
}
func NewSendAction ¶
func NewSendAction(to peer.ID, msg AppMsg) *ActionSend
func (*ActionSend) Args ¶
func (a *ActionSend) Args() []Arg
func (*ActionSend) Do ¶
func (a *ActionSend) Do(h *Holochain) (response interface{}, err error)
func (*ActionSend) Name ¶
func (a *ActionSend) Name() string
type ActionSign ¶
type ActionSign struct {
// contains filtered or unexported fields
}
func NewSignAction ¶
func NewSignAction(doc []byte) *ActionSign
func (*ActionSign) Args ¶
func (a *ActionSign) Args() []Arg
func (*ActionSign) Do ¶
func (a *ActionSign) Do(h *Holochain) (response interface{}, err error)
func (*ActionSign) Name ¶
func (a *ActionSign) Name() string
type ActionVerifySignature ¶
type ActionVerifySignature struct {
// contains filtered or unexported fields
}
------------------------------------------------------------ VerifySignature
func NewVerifySignatureAction ¶
func NewVerifySignatureAction(signature string, data string, pubKey string) *ActionVerifySignature
func (*ActionVerifySignature) Args ¶
func (a *ActionVerifySignature) Args() []Arg
func (*ActionVerifySignature) Do ¶
func (a *ActionVerifySignature) Do(h *Holochain) (response bool, err error)
func (*ActionVerifySignature) Name ¶
func (a *ActionVerifySignature) 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 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 []byte // marshaled revocation PublicKey []byte // marshaled public key }
AgentEntry structure for building AgentEntryType entries
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 BridgeApp ¶
type BridgeApp struct { H *Holochain Side int BridgeGenesisDataFrom string BridgeGenesisDataTo string Port string // only used if side == BridgeTo }
BridgeApp describes an app for bridging, used
type BridgeSpec ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket holds a list of peers.
func (*Bucket) MoveToFront ¶
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[string]int // map header hashes to index number Emap map[string]int // map entry hashes to index number // contains filtered or unexported fields }
Chain structure for providing in-memory access to chain data, entries headers and hashes
func NewChainFromFile ¶
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) 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
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 Do(h *Holochain) (response interface{}, err error) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error) CheckValidationRequest(def *EntryDef) (err error) Args() []Arg EntryType() string Entry() Entry SetHeader(header *Header) }
CommittingAction provides an abstraction for grouping actions which carry Entry data
type Config ¶
type Config struct { Port int EnableMDNS bool PeerModeAuthor bool PeerModeDHTNode bool EnableNATUPnP 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) DeleteGossiper ¶
DeleteGossiper removes a gossiper from the database
func (*DHT) DumpIdx ¶
DumpIdx converts message and data of a DHT change request to a string for human consumption
func (*DHT) FindGossiper ¶
FindGossiper picks a random DHT node to gossip with
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) GetIdxMessage ¶
GetIdxMessage returns the messages that causes the change at a given index
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) 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 string // NeighborhoodSize(integer) Establishes minimum online redundancy targets for data, and size of peer sets for sync gossip. A neighborhood size of 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. NeighborhoodSize int }
Holds the dht configuration options
type DNA ¶
type DNA struct { Version int UUID uuid.UUID Name string Properties map[string]string PropertiesSchema 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
type DelReq ¶
type DelReq struct { H Hash // hash to be deleted By Hash // hash of DelEntry on source chain took this action }
DelReq holds the data of a del request
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 }
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 Header ¶
type Header struct { Type string Time time.Time HeaderLink Hash // link to previous headerq EntryLink Hash // link to entry TypeLink Hash // link to header of previous header of this type Sig Signature Change StatusChange }
Header holds chain links, type, timestamp and signature
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(toDNA Hash, 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 for the From side
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) BuildBridge ¶
BuildBridge creates the bridge structures on both sides assumes that GenChain has been called for both sides already
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
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) 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 []byte, data string, pubKey ic.PubKey) (matches bool, err error)
VerifySignature uses the signature, data(doc) and signatory's public key to Verify the sign in contents of doc
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) 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) 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 LinkEvent ¶
LinkEvent represents the value stored in buntDB associated with a link key for one source having stored one LinkingEntry (The Link struct defined in entry.go is encoded in the key used for buntDB)
type LinkQueryResp ¶
type LinkQueryResp struct {
Links []TaggedHash
}
LinkQueryResp holds response to getLinks query
type LinkReq ¶
type LinkReq struct { Base Hash // data on which to attach the links Links Hash // hash of the source entry making the link, i.e. the req provenance }
LinkReq holds a link request
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 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 Meta ¶
type Meta struct { H Hash // hash of link-data associated T string // meta-data type identifier V []byte // meta-data }
Meta holds data that can be associated with a hash @todo, we should also be storing the meta-data source
type ModAgentOptions ¶
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 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 PutReq ¶
type PutReq struct { H Hash S int D interface{} }
PutReq holds the data of a put request
type QueryConstrain ¶
type QueryOptions ¶
type QueryOptions struct { Return QueryReturn Constrain QueryConstrain Order QueryOrder }
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) }
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 []byte, err error)
func (*SelfRevocation) Unmarshal ¶
func (r *SelfRevocation) Unmarshal(data []byte) (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 StatusChange ¶
type StatusChange struct { Action string // either AddAction, ModAction, or DelAction Hash Hash }
StatusChange records change of status of an entry in the header
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 string // the expected error 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 }
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 }
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 Do(h *Holochain) (response interface{}, err error) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error) Receive(dht *DHT, msg *Message, retries int) (response interface{}, err error) CheckValidationRequest(def *EntryDef) (err error) Args() []Arg }
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 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 fromApp BridgeTo Hash // dna Hash of toApp that this zome is a client of }
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 Entries []EntryDefFile RibosomeType string Functions []FunctionDef BridgeFuncs []string // functions in zome that can be bridged to by fromApp BridgeTo string // dna Hash of toApp that this zome is a client of }
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) 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
- agent.go
- app_package.go
- bridge.go
- bs.go
- capabilities.go
- chain.go
- change.go
- dht.go
- doc.go
- entry.go
- gossip.go
- header.go
- holochain.go
- jsribosome.go
- kad_bucket.go
- kad_lookup.go
- kad_query.go
- kad_rpc.go
- kad_table.go
- log.go
- node.go
- notifi.go
- nucleus.go
- revocation.go
- ribosome.go
- service.go
- test.go
- utils.go
- validate.go
- warrant.go
- zome.go
- zygosome.go