holochain: github.com/metacurrency/holochain Index | Files | Directories

package holochain

import "github.com/metacurrency/holochain"

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

Package 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

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 = "" /* 653 byte string literal not displayed */

)
const (
    DelEntryType   = SysEntryTypePrefix + "del"
    DelEntrySchema = "" /* 468 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"

    MigrateEntrySchema = "" /* 733 byte string literal not displayed */

    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 = "" /* 823 byte string literal not displayed */

    SampleJS = "" /* 442 byte string literal not displayed */

    SampleBinary = "" /* 3715 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 = "" /* 2955 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 + "" /* 651 byte string literal not displayed */+
    VersionStr + "" /* 10747 byte string literal not displayed */
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")

func ActionReceiver Uses

func ActionReceiver(h *Holochain, msg *Message) (response interface{}, err error)

ActionReceiver handles messages on the action protocol

func BootstrapRefreshTask Uses

func BootstrapRefreshTask(h *Holochain)

BootstrapRefreshTask refreshes our node and gets nodes from the bootstrap server

func ByteDecoder Uses

func ByteDecoder(b []byte, to interface{}) (err error)

ByteDecoder decodes data encoded by ByteEncoder

func ByteEncoder Uses

func ByteEncoder(data interface{}) (b []byte, err error)

ByteEncoder encodes anything using gob

func CleanupTestChain Uses

func CleanupTestChain(h *Holochain, d string)

func CleanupTestDir Uses

func CleanupTestDir(path string)

func CopyDir Uses

func CopyDir(source string, dest string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist.

func CopyFile Uses

func CopyFile(source string, dest string) (err error)

CopyFile copies file source to destination dest.

func DNAHashofUngenedChain Uses

func DNAHashofUngenedChain(h *Holochain) (DNAHash Hash, err error)

func Debug Uses

func Debug(m string)

Debug sends a string to the standard debug log

func Debugf Uses

func Debugf(m string, args ...interface{})

Debugf sends a formatted string to the global debug log

func DebuggingRequestedViaEnv Uses

func DebuggingRequestedViaEnv() (val, yes bool)

DebuggingRequestedViaEnv determines whether an environment var was set to enable or disable debugging

func Decode Uses

func Decode(reader io.Reader, format string, data interface{}) (err error)

Decode extracts data from the reader according to the type

func DecodeFile Uses

func DecodeFile(data interface{}, pathParts ...string) (err error)

DecodeFile decodes a file based on the extension and the data type

func DecodePubKey Uses

func DecodePubKey(b58pk string) (pubKey ic.PubKey, err error)

func DirExists Uses

func DirExists(pathParts ...string) bool

func Encode Uses

func Encode(writer io.Writer, format string, data interface{}) (err error)

Encode encodes data to the writer according to the given format

func EncodingFormat Uses

func EncodingFormat(file string) (f string)

EncodingFormat returns the files format if supported otherwise ""

func EscapeJSONValue Uses

func EscapeJSONValue(json string) string

EscapeJSONValue removed characters from a JSON value to avoid parsing issues.

func FileExists Uses

func FileExists(pathParts ...string) bool

func FileSize Uses

func FileSize(pathParts ...string) int64

func GetAllTestRoles Uses

func GetAllTestRoles(path string) (roleNameList []string, err error)

GetAllTestRoles retuns a list of the roles in a scenario

func GetTestScenarioRoles Uses

func GetTestScenarioRoles(h *Holochain, scenarioName string) (roleNameList []string, err error)

GetTestScenarioRoles returns a list of scenario roles

func GetTestScenarios Uses

func GetTestScenarios(h *Holochain) (scenarios map[string]*os.FileInfo, err error)

TestScenarioList returns a list of paths to scenario directories

func GossipReceiver Uses

func GossipReceiver(h *Holochain, m *Message) (response interface{}, err error)

GossipReceiver implements the handler for the gossip protocol

func GossipTask Uses

func GossipTask(h *Holochain)

GossipTask runs a gossip and logs any errors

func HoldingTask Uses

func HoldingTask(h *Holochain)

func Info Uses

func Info(m string)

Info sends a string to the global info log

func Infof Uses

func Infof(m string, args ...interface{})

Infof sends a formatted string to the standard info log

func InitializeHolochain Uses

func InitializeHolochain()

InitializeHolochain setup function that must be called once at startup by the application that uses this holochain library

func IsInitialized Uses

func IsInitialized(root string) bool

IsInitialized checks a path for a correctly set up .holochain directory

func IsValidationFailedErr Uses

func IsValidationFailedErr(err error) bool

func KademliaReceiver Uses

func KademliaReceiver(h *Holochain, m *Message) (response interface{}, err error)

KademliaReceiver implements the handler for the kademlia RPC protocol messages

func LoadTestFiles Uses

func LoadTestFiles(path string) (map[string]TestSet, error)

LoadTestFiles searches a path for .json test files and loads them into an array

func MakeDirs Uses

func MakeDirs(devPath string) error

MakeDirs creates the directory structure of an application

func MakeReceiptData Uses

func MakeReceiptData(msg *Message, code int) (reciept []byte, err error)

MakeReceiptData converts a message and a code into signable data

func MakeTestDirName Uses

func MakeTestDirName() string

func MakeTestSeed Uses

func MakeTestSeed(id string) io.Reader

func MarshalEntry Uses

func MarshalEntry(writer io.Writer, e Entry) (err error)

MarshalEntry serializes an entry to a writer

func MarshalHeader Uses

func MarshalHeader(writer io.Writer, hd *Header) (err error)

MarshalHeader writes a header to a binary stream

func MarshalSignature Uses

func MarshalSignature(writer io.Writer, s *Signature) (err error)

MarshalSignature writes a signature to a binary stream

func NormaliseJSON Uses

func NormaliseJSON(json string) string

func Panix Uses

func Panix(on string)

func PrepareTestChain Uses

func PrepareTestChain(n string) (d string, s *Service, h *Holochain)

func PrettyPrintJSON Uses

func PrettyPrintJSON(b []byte) (string, error)

PrettyPrintJSON for human reability.

func ReadFile Uses

func ReadFile(pathParts ...string) (data []byte, err error)

func RegisterBultinRibosomes Uses

func RegisterBultinRibosomes()

RegisterBultinRibosomes adds the built in ribosome types to the factory hash

func RegisterRibosome Uses

func RegisterRibosome(name string, factory RibosomeFactory)

RegisterRibosome sets up a Ribosome to be used by the CreateRibosome function

func RetryTask Uses

func RetryTask(h *Holochain)

RetryTask checks to see if there are any received puts that need retrying and does one if so

func RoutingRefreshTask Uses

func RoutingRefreshTask(h *Holochain)

RoutingRefreshTask fills the routing table by searching for a random node

func RunValidationPhase Uses

func RunValidationPhase(h *Holochain, source peer.ID, msgType MsgType, query Hash, handler func(resp ValidateResponse) error) (err error)

func SaveAgent Uses

func SaveAgent(path string, agent Agent) (err error)

SaveAgent saves out the keys and agent name to the given directory

func SetAgentIdentity Uses

func SetAgentIdentity(agent Agent, identity AgentIdentity)

func SetIdentity Uses

func SetIdentity(h *Holochain, identity AgentIdentity)

func SetupTestChain Uses

func SetupTestChain(n string) (d string, s *Service, h *Holochain)

func SetupTestDir Uses

func SetupTestDir() string

func ShouldLog Uses

func ShouldLog(log *Logger, fn func(), messages ...string)

func SortClosestPeers Uses

func SortClosestPeers(peers []peer.ID, target Hash) []peer.ID

func TestingAppAppPackage Uses

func TestingAppAppPackage() string

func Ticker Uses

func Ticker(interval time.Duration, fn func()) (stopper chan bool)

Ticker runs a function on an interval that can be stopped with the returned bool channel

func UnmarshalHeader Uses

func UnmarshalHeader(reader io.Reader, hd *Header, hashSize int) (err error)

UnmarshalHeader reads a Header from a binary stream

func UnmarshalSignature Uses

func UnmarshalSignature(reader io.Reader, s *Signature) (err error)

UnmarshalSignature reads a Signature from a binary stream

func ValidateReceiver Uses

func ValidateReceiver(h *Holochain, msg *Message) (response interface{}, err error)

ValidateReceiver handles messages on the Validate protocol

func ValidationFailed Uses

func ValidationFailed(msgs ...string) error

ValidationFailed creates a validation failed error message

func WriteFile Uses

func WriteFile(data []byte, pathParts ...string) error

type APIFnBridge Uses

type APIFnBridge struct {
    // contains filtered or unexported fields
}

func (*APIFnBridge) Args Uses

func (fn *APIFnBridge) Args() []Arg

func (*APIFnBridge) Call Uses

func (fn *APIFnBridge) Call(h *Holochain) (response interface{}, err error)

func (*APIFnBridge) Name Uses

func (fn *APIFnBridge) Name() string

type APIFnCall Uses

type APIFnCall struct {
    // contains filtered or unexported fields
}

func (*APIFnCall) Args Uses

func (fn *APIFnCall) Args() []Arg

func (*APIFnCall) Call Uses

func (fn *APIFnCall) Call(h *Holochain) (response interface{}, err error)

func (*APIFnCall) Name Uses

func (fn *APIFnCall) Name() string

type APIFnCloseBundle Uses

type APIFnCloseBundle struct {
    // contains filtered or unexported fields
}

func (*APIFnCloseBundle) Args Uses

func (a *APIFnCloseBundle) Args() []Arg

func (*APIFnCloseBundle) Call Uses

func (a *APIFnCloseBundle) Call(h *Holochain) (response interface{}, err error)

func (*APIFnCloseBundle) Name Uses

func (a *APIFnCloseBundle) Name() string

type APIFnCommit Uses

type APIFnCommit struct {
    // contains filtered or unexported fields
}

func (*APIFnCommit) Args Uses

func (fn *APIFnCommit) Args() []Arg

func (*APIFnCommit) Call Uses

func (fn *APIFnCommit) Call(h *Holochain) (response interface{}, err error)

func (*APIFnCommit) Name Uses

func (fn *APIFnCommit) Name() string

func (*APIFnCommit) SetAction Uses

func (fn *APIFnCommit) SetAction(a *ActionCommit)

type APIFnDebug Uses

type APIFnDebug struct {
    // contains filtered or unexported fields
}

func (*APIFnDebug) Args Uses

func (a *APIFnDebug) Args() []Arg

func (*APIFnDebug) Call Uses

func (a *APIFnDebug) Call(h *Holochain) (response interface{}, err error)

func (*APIFnDebug) Name Uses

func (a *APIFnDebug) Name() string

type APIFnDel Uses

type APIFnDel struct {
    // contains filtered or unexported fields
}

func (*APIFnDel) Args Uses

func (fn *APIFnDel) Args() []Arg

func (*APIFnDel) Call Uses

func (fn *APIFnDel) Call(h *Holochain) (response interface{}, err error)

func (*APIFnDel) Name Uses

func (fn *APIFnDel) Name() string

type APIFnGet Uses

type APIFnGet struct {
    // contains filtered or unexported fields
}

func (*APIFnGet) Args Uses

func (fn *APIFnGet) Args() []Arg

func (*APIFnGet) Call Uses

func (fn *APIFnGet) Call(h *Holochain) (response interface{}, err error)

func (*APIFnGet) Name Uses

func (fn *APIFnGet) Name() string

type APIFnGetBridges Uses

type APIFnGetBridges struct {
}

func (*APIFnGetBridges) Args Uses

func (a *APIFnGetBridges) Args() []Arg

func (*APIFnGetBridges) Call Uses

func (a *APIFnGetBridges) Call(h *Holochain) (response interface{}, err error)

func (*APIFnGetBridges) Name Uses

func (a *APIFnGetBridges) Name() string
type APIFnGetLinks struct {
    // contains filtered or unexported fields
}

func (*APIFnGetLinks) Args Uses

func (fn *APIFnGetLinks) Args() []Arg

func (*APIFnGetLinks) Call Uses

func (fn *APIFnGetLinks) Call(h *Holochain) (response interface{}, err error)

func (*APIFnGetLinks) Name Uses

func (fn *APIFnGetLinks) Name() string

type APIFnMakeHash Uses

type APIFnMakeHash struct {
    // contains filtered or unexported fields
}

func (*APIFnMakeHash) Args Uses

func (a *APIFnMakeHash) Args() []Arg

func (*APIFnMakeHash) Call Uses

func (a *APIFnMakeHash) Call(h *Holochain) (response interface{}, err error)

func (*APIFnMakeHash) Name Uses

func (a *APIFnMakeHash) Name() string

type APIFnMigrate Uses

type APIFnMigrate struct {
    // contains filtered or unexported fields
}

func (*APIFnMigrate) Args Uses

func (fn *APIFnMigrate) Args() []Arg

func (*APIFnMigrate) Call Uses

func (fn *APIFnMigrate) Call(h *Holochain) (response interface{}, err error)

func (*APIFnMigrate) Name Uses

func (fn *APIFnMigrate) Name() string

type APIFnMod Uses

type APIFnMod struct {
    // contains filtered or unexported fields
}

func (*APIFnMod) Args Uses

func (fn *APIFnMod) Args() []Arg

func (*APIFnMod) Call Uses

func (fn *APIFnMod) Call(h *Holochain) (response interface{}, err error)

func (*APIFnMod) Name Uses

func (fn *APIFnMod) Name() string

type APIFnModAgent Uses

type APIFnModAgent struct {
    Identity   AgentIdentity
    Revocation string
}

func (*APIFnModAgent) Args Uses

func (fn *APIFnModAgent) Args() []Arg

func (*APIFnModAgent) Call Uses

func (fn *APIFnModAgent) Call(h *Holochain) (response interface{}, err error)

func (*APIFnModAgent) Name Uses

func (fn *APIFnModAgent) Name() string

type APIFnProperty Uses

type APIFnProperty struct {
    // contains filtered or unexported fields
}

func (*APIFnProperty) Args Uses

func (a *APIFnProperty) Args() []Arg

func (*APIFnProperty) Call Uses

func (a *APIFnProperty) Call(h *Holochain) (response interface{}, err error)

func (*APIFnProperty) Name Uses

func (a *APIFnProperty) Name() string

type APIFnQuery Uses

type APIFnQuery struct {
    // contains filtered or unexported fields
}

func (*APIFnQuery) Args Uses

func (a *APIFnQuery) Args() []Arg

func (*APIFnQuery) Call Uses

func (a *APIFnQuery) Call(h *Holochain) (response interface{}, err error)

func (*APIFnQuery) Name Uses

func (a *APIFnQuery) Name() string

type APIFnSend Uses

type APIFnSend struct {
    // contains filtered or unexported fields
}

func (*APIFnSend) Args Uses

func (fn *APIFnSend) Args() []Arg

func (*APIFnSend) Call Uses

func (fn *APIFnSend) Call(h *Holochain) (response interface{}, err error)

func (*APIFnSend) Name Uses

func (fn *APIFnSend) Name() string

type APIFnSign Uses

type APIFnSign struct {
    // contains filtered or unexported fields
}

func (*APIFnSign) Args Uses

func (a *APIFnSign) Args() []Arg

func (*APIFnSign) Call Uses

func (a *APIFnSign) Call(h *Holochain) (response interface{}, err error)

func (*APIFnSign) Name Uses

func (a *APIFnSign) Name() string

type APIFnStartBundle Uses

type APIFnStartBundle struct {
    // contains filtered or unexported fields
}

func NewStartBundleAction Uses

func NewStartBundleAction(timeout int, userParam string) *APIFnStartBundle

func (*APIFnStartBundle) Args Uses

func (a *APIFnStartBundle) Args() []Arg

func (*APIFnStartBundle) Call Uses

func (a *APIFnStartBundle) Call(h *Holochain) (response interface{}, err error)

func (*APIFnStartBundle) Name Uses

func (a *APIFnStartBundle) Name() string

type APIFnVerifySignature Uses

type APIFnVerifySignature struct {
    // contains filtered or unexported fields
}

func (*APIFnVerifySignature) Args Uses

func (a *APIFnVerifySignature) Args() []Arg

func (*APIFnVerifySignature) Call Uses

func (a *APIFnVerifySignature) Call(h *Holochain) (response interface{}, err error)

func (*APIFnVerifySignature) Name Uses

func (a *APIFnVerifySignature) Name() string

type APIFunction Uses

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 Uses

type Action interface {
    Name() string
    Receive(dht *DHT, msg *Message) (response interface{}, err error)
}

Action provides an abstraction for handling node interaction

func MakeActionFromMessage Uses

func MakeActionFromMessage(msg *Message) (a Action, err error)

MakeActionFromMessage generates an action from an action protocol messsage

type ActionCommit Uses

type ActionCommit struct {
    // contains filtered or unexported fields
}

func NewCommitAction Uses

func NewCommitAction(entryType string, entry Entry) *ActionCommit

func (*ActionCommit) CheckValidationRequest Uses

func (a *ActionCommit) CheckValidationRequest(def *EntryDef) (err error)

func (*ActionCommit) Entry Uses

func (a *ActionCommit) Entry() Entry

func (*ActionCommit) EntryType Uses

func (a *ActionCommit) EntryType() string

func (*ActionCommit) GetHeader Uses

func (a *ActionCommit) GetHeader() (header *Header)

func (*ActionCommit) Name Uses

func (a *ActionCommit) Name() string

func (*ActionCommit) Receive Uses

func (a *ActionCommit) Receive(dht *DHT, msg *Message) (response interface{}, err error)

func (*ActionCommit) SetHeader Uses

func (a *ActionCommit) SetHeader(header *Header)

func (*ActionCommit) Share Uses

func (a *ActionCommit) Share(h *Holochain, def *EntryDef) (err error)

func (*ActionCommit) SysValidation Uses

func (a *ActionCommit) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)

type ActionDel Uses

type ActionDel struct {
    // contains filtered or unexported fields
}

func NewDelAction Uses

func NewDelAction(entry DelEntry) *ActionDel

func (*ActionDel) CheckValidationRequest Uses

func (a *ActionDel) CheckValidationRequest(def *EntryDef) (err error)

func (*ActionDel) Entry Uses

func (a *ActionDel) Entry() Entry

func (*ActionDel) EntryType Uses

func (a *ActionDel) EntryType() string

func (*ActionDel) GetHeader Uses

func (a *ActionDel) GetHeader() (header *Header)

func (*ActionDel) Name Uses

func (a *ActionDel) Name() string

func (*ActionDel) Receive Uses

func (a *ActionDel) Receive(dht *DHT, msg *Message) (response interface{}, err error)

func (*ActionDel) SetHeader Uses

func (a *ActionDel) SetHeader(header *Header)

func (*ActionDel) Share Uses

func (a *ActionDel) Share(h *Holochain, def *EntryDef) (err error)

func (*ActionDel) SysValidation Uses

func (a *ActionDel) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)

type ActionGet Uses

type ActionGet struct {
    // contains filtered or unexported fields
}

func (*ActionGet) Name Uses

func (a *ActionGet) Name() string

func (*ActionGet) Receive Uses

func (a *ActionGet) Receive(dht *DHT, msg *Message) (response interface{}, err error)

func (*ActionGet) SysValidation Uses

func (a *ActionGet) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)
type ActionGetLinks struct {
    // contains filtered or unexported fields
}

func NewGetLinksAction Uses

func NewGetLinksAction(linkQuery *LinkQuery, options *GetLinksOptions) *ActionGetLinks

func (*ActionGetLinks) Name Uses

func (a *ActionGetLinks) Name() string

func (*ActionGetLinks) Receive Uses

func (a *ActionGetLinks) Receive(dht *DHT, msg *Message) (response interface{}, err error)

func (*ActionGetLinks) SysValidation Uses

func (a *ActionGetLinks) SysValidation(h *Holochain, d *EntryDef, pkg *Package, sources []peer.ID) (err error)
type ActionLink struct {
    // contains filtered or unexported fields
}

func NewLinkAction Uses

func NewLinkAction(entryType string, links []Link) *ActionLink

func (*ActionLink) CheckValidationRequest Uses

func (a *ActionLink) CheckValidationRequest(def *EntryDef) (err error)

func (*ActionLink) Name Uses

func (a *ActionLink) Name() string

func (*ActionLink) Receive Uses

func (a *ActionLink) Receive(dht *DHT, msg *Message) (response interface{}, err error)

func (*ActionLink) SysValidation Uses

func (a *ActionLink) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)

type ActionListAdd Uses

type ActionListAdd struct {
    // contains filtered or unexported fields
}

func NewListAddAction Uses

func NewListAddAction(peerList PeerList) *ActionListAdd

func (*ActionListAdd) Name Uses

func (a *ActionListAdd) Name() string

func (*ActionListAdd) Receive Uses

func (a *ActionListAdd) Receive(dht *DHT, msg *Message) (response interface{}, err error)

type ActionMigrate Uses

type ActionMigrate struct {
    // contains filtered or unexported fields
}

func (*ActionMigrate) CheckValidationRequest Uses

func (a *ActionMigrate) CheckValidationRequest(def *EntryDef) (err error)

func (*ActionMigrate) Entry Uses

func (a *ActionMigrate) Entry() Entry

func (*ActionMigrate) EntryType Uses

func (a *ActionMigrate) EntryType() string

func (*ActionMigrate) GetHeader Uses

func (a *ActionMigrate) GetHeader() (header *Header)

func (*ActionMigrate) Name Uses

func (a *ActionMigrate) Name() string

func (*ActionMigrate) Receive Uses

func (a *ActionMigrate) Receive(dht *DHT, msg *Message) (response interface{}, err error)

func (*ActionMigrate) SetHeader Uses

func (a *ActionMigrate) SetHeader(header *Header)

func (*ActionMigrate) Share Uses

func (action *ActionMigrate) Share(h *Holochain, def *EntryDef) (err error)

func (*ActionMigrate) SysValidation Uses

func (action *ActionMigrate) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)

type ActionMod Uses

type ActionMod struct {
    // contains filtered or unexported fields
}

func NewModAction Uses

func NewModAction(entryType string, entry Entry, replaces Hash) *ActionMod

func (*ActionMod) CheckValidationRequest Uses

func (a *ActionMod) CheckValidationRequest(def *EntryDef) (err error)

func (*ActionMod) Entry Uses

func (a *ActionMod) Entry() Entry

func (*ActionMod) EntryType Uses

func (a *ActionMod) EntryType() string

func (*ActionMod) GetHeader Uses

func (a *ActionMod) GetHeader() (header *Header)

func (*ActionMod) Name Uses

func (a *ActionMod) Name() string

func (*ActionMod) Receive Uses

func (a *ActionMod) Receive(dht *DHT, msg *Message) (response interface{}, err error)

func (*ActionMod) SetHeader Uses

func (a *ActionMod) SetHeader(header *Header)

func (*ActionMod) Share Uses

func (a *ActionMod) Share(h *Holochain, def *EntryDef) (err error)

func (*ActionMod) SysValidation Uses

func (a *ActionMod) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)

type ActionPut Uses

type ActionPut struct {
    // contains filtered or unexported fields
}

func NewPutAction Uses

func NewPutAction(entryType string, entry Entry, header *Header) *ActionPut

func (*ActionPut) CheckValidationRequest Uses

func (a *ActionPut) CheckValidationRequest(def *EntryDef) (err error)

func (*ActionPut) Name Uses

func (a *ActionPut) Name() string

func (*ActionPut) Receive Uses

func (a *ActionPut) Receive(dht *DHT, msg *Message) (response interface{}, err error)

func (*ActionPut) SysValidation Uses

func (a *ActionPut) SysValidation(h *Holochain, def *EntryDef, pkg *Package, sources []peer.ID) (err error)

type ActionSend Uses

type ActionSend struct {
    // contains filtered or unexported fields
}

func (*ActionSend) Name Uses

func (a *ActionSend) Name() string

func (*ActionSend) Receive Uses

func (a *ActionSend) Receive(dht *DHT, msg *Message) (response interface{}, err error)

type Agent Uses

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

func LoadAgent Uses

func LoadAgent(path string) (agent Agent, err error)

LoadAgent gets the agent identity and private key from the specified directory TODO confirm against chain?

func NewAgent Uses

func NewAgent(agentType AgentType, identity AgentIdentity, seed io.Reader) (agent Agent, err error)

NewAgent creates an agent structure of the given type Note: currently only IPFS agents are implemented

type AgentEntry Uses

type AgentEntry struct {
    Identity   AgentIdentity
    Revocation string // marshaled revocation
    PublicKey  string // marshaled public key
}

AgentEntry structure for building AgentEntryType entries

func AgentEntryFromJSON Uses

func AgentEntryFromJSON(j string) (entry AgentEntry, err error)

func (*AgentEntry) ToJSON Uses

func (ae *AgentEntry) ToJSON() (encodedEntry string, err error)

type AgentFixture Uses

type AgentFixture struct {
    Hash     string
    Identity string
}

AgentFixture defines an agent for the purposes of tests

type AgentIdentity Uses

type AgentIdentity string

AgentIdentity is the user's unique identity information in context of this holochain. it follows AgentIdentitySchema in DNA

type AgentType Uses

type AgentType int

type AppMsg Uses

type AppMsg struct {
    ZomeType string
    Body     string
}

type AppPackage Uses

type AppPackage struct {
    Version   string
    Generator string
    DNA       DNA
    TestSets  []AppPackageTests
    UI        []AppPackageUIFile
    Scenarios []AppPackageScenario
}

func LoadAppPackage Uses

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 Uses

type AppPackageScenario struct {
    Name   string
    Roles  []AppPackageTests
    Config TestConfig
}

type AppPackageTests Uses

type AppPackageTests struct {
    Name    string
    TestSet TestSet
}

type AppPackageUIFile Uses

type AppPackageUIFile struct {
    FileName string
    Data     string
    Encoding string
}

type Arg Uses

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 ArgType Uses

type ArgType int8

type BSReq Uses

type BSReq struct {
    Version  int
    NodeID   string
    NodeAddr string
}

type BSResp Uses

type BSResp struct {
    Req      BSReq
    Remote   string
    LastSeen time.Time
}

type Bridge Uses

type Bridge struct {
    CalleeApp  Hash
    CalleeName string
    Token      string
    Side       int
}

Bridge holds data returned by GetBridges

type BridgeApp Uses

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 Uses

type BridgeSpec map[string]map[string]bool

type Bucket Uses

type Bucket struct {
    // contains filtered or unexported fields
}

Bucket holds a list of peers.

func (*Bucket) Has Uses

func (b *Bucket) Has(id peer.ID) bool

func (*Bucket) Len Uses

func (b *Bucket) Len() int

func (*Bucket) MoveToFront Uses

func (b *Bucket) MoveToFront(id peer.ID)

func (*Bucket) Peers Uses

func (b *Bucket) Peers() []peer.ID

func (*Bucket) PopBack Uses

func (b *Bucket) PopBack() peer.ID

func (*Bucket) PushFront Uses

func (b *Bucket) PushFront(p peer.ID)

func (*Bucket) Remove Uses

func (b *Bucket) Remove(id peer.ID)

func (*Bucket) Split Uses

func (b *Bucket) Split(cpl int, target peer.ID) *Bucket

Split splits a buckets peers into two buckets, the methods receiver will have peers with CPL equal to cpl, the returned bucket will have peers with CPL greater than cpl (returned bucket has closer peers)

type Bundle Uses

type Bundle struct {
    // contains filtered or unexported fields
}

type BuntHT Uses

type BuntHT struct {
    // contains filtered or unexported fields
}

func (*BuntHT) Close Uses

func (ht *BuntHT) Close()

Close cleans up any resources used by the table

func (*BuntHT) Del Uses

func (ht *BuntHT) Del(m *Message, key Hash) (err error)

Del moves the given hash to the StatusDeleted status N.B. this functions assumes that the validity of this action has been confirmed

func (ht *BuntHT) DelLink(m *Message, base string, link string, tag string) (err error)

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) Exists Uses

func (ht *BuntHT) Exists(key Hash, statusMask int) (err error)

Exists checks for the existence of the hash in the store

func (*BuntHT) Get Uses

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) GetIdx Uses

func (ht *BuntHT) GetIdx() (idx int, err error)

GetIdx returns the current index of changes to the HashTable

func (*BuntHT) GetIdxMessage Uses

func (ht *BuntHT) GetIdxMessage(idx int) (msg Message, err error)

GetIdxMessage returns the messages that causes the change at a given index

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 Uses

func (ht *BuntHT) Iterate(fn HashTableIterateFn)

func (*BuntHT) JSON Uses

func (ht *BuntHT) JSON() (result string, err error)

JSON converts the table into a JSON string representation.

func (*BuntHT) Mod Uses

func (ht *BuntHT) Mod(m *Message, key Hash, newkey Hash) (err error)

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) Open Uses

func (ht *BuntHT) Open(options interface{}) (err error)

func (*BuntHT) Put Uses

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 (ht *BuntHT) PutLink(m *Message, base string, link string, tag string) (err error)

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 (*BuntHT) Source Uses

func (ht *BuntHT) Source(key Hash) (id peer.ID, err error)

Source returns the source node address of a given hash

func (*BuntHT) String Uses

func (ht *BuntHT) String() (result string)

String converts the table into a human readable string

type BytesSent Uses

type BytesSent struct {
    Bytes   int64
    MsgType MsgType
}

type Callback Uses

type Callback struct {
    Function string
    ID       string
    // contains filtered or unexported fields
}

type Capability Uses

type Capability struct {
    Token string
    // contains filtered or unexported fields
}

func NewCapability Uses

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 Uses

func (c *Capability) Revoke(who interface{}) (err error)

Revoke unregisters the capability for a peer

func (*Capability) Validate Uses

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 Uses

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 NewChain Uses

func NewChain(hashSpec HashSpec) (chain *Chain)

NewChain creates and empty chain

func NewChainFromFile Uses

func NewChainFromFile(spec HashSpec, path string) (c *Chain, err error)

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 Uses

func UnmarshalChain(hashSpec HashSpec, reader io.Reader) (flags int64, c *Chain, err error)

UnmarshalChain unserializes a chain from a reader

func (*Chain) AddEntry Uses

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 Uses

func (c *Chain) BundleStarted() *Bundle

BundleStarted returns the index of the chain item before the bundle or 0 if no bundle is active

func (*Chain) Close Uses

func (c *Chain) Close()

Close the chain's file

func (*Chain) CloseBundle Uses

func (c *Chain) CloseBundle(commit bool) (err error)

CloseBundle closes a started bundle and if commit copies entries from the bundle onto the chain

func (*Chain) Dot Uses

func (c *Chain) Dot(start int) (dump string, err error)

Dot converts a chain to a GraphViz 'dot' format dump of the headers and entries

func (*Chain) Dump Uses

func (c *Chain) Dump(start int) string

Dump converts a chain to a textual dump of the headers and entries from a starting index

func (*Chain) Get Uses

func (c *Chain) Get(h Hash) (header *Header, err error)

Get returns the header of a given hash

func (*Chain) GetEntry Uses

func (c *Chain) GetEntry(h Hash) (entry Entry, entryType string, err error)

GetEntry returns the entry of a given entry hash

func (*Chain) GetEntryHeader Uses

func (c *Chain) GetEntryHeader(h Hash) (header *Header, err error)

GetEntryHeader returns the header of a given entry hash

func (*Chain) JSON Uses

func (c *Chain) JSON(start int) (string, error)

JSON converts a chain to a json string dump of the headers and entries

func (*Chain) Length Uses

func (c *Chain) Length() int

Length returns the number of entries in the chain

func (*Chain) MarshalChain Uses

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) Nth Uses

func (c *Chain) Nth(n int) (header *Header)

Nth returns the nth latest header

func (*Chain) StartBundle Uses

func (c *Chain) StartBundle(userParam interface{}) (err error)

StartBundle marks a bundle start point and returns an error if already started

func (*Chain) String Uses

func (c *Chain) String() string

String converts a chain to a textual dump of the headers and entries

func (*Chain) Top Uses

func (c *Chain) Top() (header *Header)

Top returns the latest header

func (*Chain) TopType Uses

func (c *Chain) TopType(entryType string) (hash *Hash, header *Header)

TopType returns the latest header of a given type

func (*Chain) Validate Uses

func (c *Chain) Validate(skipEntries bool) (err error)

Validate traverses chain confirming the hashes @TODO confirm that TypeLinks are also correct @TODO confirm signatures

func (*Chain) Walk Uses

func (c *Chain) Walk(fn WalkerFn) (err error)

Walk traverses chain from most recent to first entry calling fn on each one

type ChainPair Uses

type ChainPair struct {
    Header *Header
    Entry  Entry
}

type Change Uses

type Change struct {
    Type    ChangeType
    Message string
    AsOf    int
}

Change represents a semantic change that needs to be reported

func (*Change) Log Uses

func (c *Change) Log()

type ChangeType Uses

type ChangeType int8
const (
    Deprecation ChangeType = iota
    Warning
)

type Channel Uses

type Channel chan interface{}

type CloneSpec Uses

type CloneSpec struct {
    Role   string
    Number int
}

type CloserPeersResp Uses

type CloserPeersResp struct {
    CloserPeers []PeerInfo // note this is not a pstore.PeerInfo which can't be serialized by gob.
}

type CommittingAction Uses

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)
    // Low level implementation of putting to DHT (assumes validation has been done)
    Share(h *Holochain, def *EntryDef) (err error)
}

CommittingAction provides an abstraction for grouping actions which carry Entry data

type Config Uses

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 Uses

func (config *Config) SetGossipInterval(interval time.Duration)

func (*Config) Setup Uses

func (config *Config) Setup() (err error)

func (*Config) SetupLogging Uses

func (config *Config) SetupLogging() (err error)

SetupLogging initializes loggers as configured by the config file and environment variables

type DHT Uses

type DHT struct {
    // contains filtered or unexported fields
}

DHT struct holds the data necessary to run the distributed hash table

func NewDHT Uses

func NewDHT(h *Holochain) *DHT

NewDHT creates a new DHT structure

func (*DHT) AddGossiper Uses

func (dht *DHT) AddGossiper(id peer.ID) (err error)

AddGossiper adds a new gossiper to the gossiper store

func (*DHT) Change Uses

func (dht *DHT) Change(key Hash, msgType MsgType, body interface{}) (err error)

Change sends DHT change messages to the closest peers to the hash in question

func (*DHT) Close Uses

func (dht *DHT) Close()

Close cleans up the DHT

func (*DHT) Del Uses

func (dht *DHT) Del(m *Message, key Hash) (err error)

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 *DHT) DelLink(m *Message, base string, link string, tag string) (err error)

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 Uses

func (dht *DHT) DeleteGossiper(id peer.ID) (err error)

DeleteGossiper removes a gossiper from the database

func (*DHT) Exists Uses

func (dht *DHT) Exists(key Hash, statusMask int) (err error)

Exists checks for the existence of the hash in the store

func (*DHT) FindGossiper Uses

func (dht *DHT) FindGossiper() (g peer.ID, err error)

FindGossiper picks a random DHT node to gossip with

func (*DHT) Get Uses

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 Uses

func (dht *DHT) GetFingerprint(f Hash) (index int, err error)

GetFingerprint returns the index that of the message that made a change or -1 if we don't have it

func (*DHT) GetGossiper Uses

func (dht *DHT) GetGossiper(id peer.ID) (idx int, err error)

GetGossiper loads returns last known index of the gossiper, and adds them if not didn't exist before

func (*DHT) GetGossipers Uses

func (dht *DHT) GetGossipers() (gossipers []GossiperData, err error)

func (*DHT) GetIdx Uses

func (dht *DHT) GetIdx() (idx int, err error)

GetIdx returns the current index of changes to the HashTable

func (*DHT) GetIdxMessage Uses

func (dht *DHT) GetIdxMessage(idx int) (msg Message, err error)

GetIdxMessage returns the messages that causes the change at a given index

func (dht *DHT) GetLinks(base Hash, tag string, statusMask int) (results []TaggedHash, err error)

GetLinks retrieves meta value associated with a base

func (*DHT) GetPuts Uses

func (dht *DHT) GetPuts(since int) (puts []Put, err error)

GetPuts returns a list of puts after the given index

func (*DHT) HandleChangeRequests Uses

func (dht *DHT) HandleChangeRequests() (err error)

HandleChangeRequests waits on a channel for dht change requests

func (*DHT) HandleGossipPuts Uses

func (dht *DHT) HandleGossipPuts() (err error)

HandleGossipPuts waits on a channel for gossip changes

func (*DHT) HandleGossipWiths Uses

func (dht *DHT) HandleGossipWiths() (err error)

HandleGossipWiths waits on a channel for gossipWith requests

func (*DHT) HaveFingerprint Uses

func (dht *DHT) HaveFingerprint(f Hash) (result bool, err error)

HaveFingerprint returns true if we have seen the given fingerprint

func (*DHT) Iterate Uses

func (dht *DHT) Iterate(fn HashTableIterateFn)

func (*DHT) JSON Uses

func (dht *DHT) JSON() (result string, err error)

JSON converts a DHT into a JSON string representation.

func (*DHT) MakeHoldResp Uses

func (dht *DHT) MakeHoldResp(msg *Message, status int) (holdResp *HoldResp, err error)

MakeHoldResp creates fill the HoldResp struct with a the holding status and signature

func (*DHT) MakeReceiptSignature Uses

func (dht *DHT) MakeReceiptSignature(msg *Message, code int) (sig Signature, err error)

MakeReceipt creates a signature of a message together with the receipt code

func (*DHT) Mod Uses

func (dht *DHT) Mod(m *Message, key Hash, newkey Hash) (err error)

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) Open Uses

func (dht *DHT) Open(options interface{}) (err error)

Open sets up the DHTs data structures and store

func (*DHT) Put Uses

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 *DHT) PutLink(m *Message, base string, link string, tag string) (err error)

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 Uses

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 Uses

func (dht *DHT) SetupDHT() (err error)

SetupDHT prepares a DHT for use by putting the genesis entries that are added by GenChain

func (*DHT) Source Uses

func (dht *DHT) Source(key Hash) (id peer.ID, err error)

Source returns the source node address of a given hash

func (*DHT) Start Uses

func (dht *DHT) Start() (err error)

Start initiates listening for DHT & Gossip protocol messages on the node

func (*DHT) String Uses

func (dht *DHT) String() (result string)

String converts a DHT into a human readable string

func (*DHT) UpdateGossiper Uses

func (dht *DHT) UpdateGossiper(id peer.ID, newIdx int) (err error)

UpdateGossiper updates a gossiper

type DHTConfig Uses

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 Uses

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
}

func (*DNA) NewUUID Uses

func (dna *DNA) NewUUID() (err error)

NewUUID generates a new UUID for the DNA

type DNAFile Uses

type DNAFile struct {
    Version              int
    UUID                 uuid.UUID
    Name                 string
    Properties           map[string]string
    PropertiesSchemaFile string
    BasedOn              Hash // references hash of another holochain that these schemas and code are derived from
    RequiresVersion      int
    DHTConfig            DHTConfig
    Progenitor           Progenitor
    Zomes                []ZomeFile
}

type DelEntry Uses

type DelEntry struct {
    Hash    Hash
    Message string
}

DelEntry struct holds the record of an entry's deletion

func DelEntryFromJSON Uses

func DelEntryFromJSON(j string) (entry DelEntry, err error)

func (*DelEntry) ToJSON Uses

func (e *DelEntry) ToJSON() (encodedEntry string, err error)

type Entry Uses

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

func UnmarshalEntry Uses

func UnmarshalEntry(reader io.Reader) (e Entry, err error)

UnmarshalEntry unserializes an entry from a reader

type EntryDef Uses

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 Uses

func (d *EntryDef) BuildJSONSchemaValidator(path string) (err error)

BuildJSONSchemaValidator builds a validator in an EntryDef

func (*EntryDef) BuildJSONSchemaValidatorFromString Uses

func (d *EntryDef) BuildJSONSchemaValidatorFromString(schema string) (err error)

func (*EntryDef) IsSysEntry Uses

func (def *EntryDef) IsSysEntry() bool

IsSysEntry returns true if the entry type is system defined

func (*EntryDef) IsVirtualEntry Uses

func (def *EntryDef) IsVirtualEntry() bool

IsVirtualEntry returns true if the entry type is virtual

type EntryDefFile Uses

type EntryDefFile struct {
    Name       string
    DataFormat string
    Schema     string
    SchemaFile string // file name of schema or language schema directive
    Sharing    string
}

type ErrorResponse Uses

type ErrorResponse struct {
    Code    int
    Message string
    Payload interface{}
}

func NewErrorResponse Uses

func NewErrorResponse(err error) (errResp ErrorResponse)

NewErrorResponse encodes standard errors for transmitting

func (ErrorResponse) DecodeResponseError Uses

func (errResp ErrorResponse) DecodeResponseError() (err error)

DecodeResponseError creates a go error object from the ErrorResponse data

type FindNodeReq Uses

type FindNodeReq struct {
    H Hash
}

type FunctionDef Uses

type FunctionDef struct {
    Name        string
    CallingType string
    Exposure    string
}

FunctionDef holds the name and calling type of an DNA exposed function

func (*FunctionDef) ValidExposure Uses

func (f *FunctionDef) ValidExposure(context string) bool

ValidExposure verifies that the function can be called in the given context

type GetLinksOptions Uses

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 Uses

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 GetReq Uses

type GetReq struct {
    H          Hash
    StatusMask int
    GetMask    int
}

GetReq holds the data of a get request

type GetResp Uses

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 Uses

type GobEntry struct {
    C interface{}
}

GobEntry is a structure for implementing Gob encoding of Entry content

func (*GobEntry) Content Uses

func (e *GobEntry) Content() interface{}

func (*GobEntry) Marshal Uses

func (e *GobEntry) Marshal() (b []byte, err error)

func (*GobEntry) Sum Uses

func (e *GobEntry) Sum(s HashSpec) (h Hash, err error)

func (*GobEntry) Unmarshal Uses

func (e *GobEntry) Unmarshal(b []byte) (err error)

type Gossip Uses

type Gossip struct {
    Puts []Put
}

Gossip holds a gossip message

type GossipReq Uses

type GossipReq struct {
    MyIdx   int
    YourIdx int
}

GossipReq holds a gossip request

type GossiperData Uses

type GossiperData struct {
    ID     peer.ID
    PutIdx int
}

type HashTable Uses

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 Uses

type HashTableIterateFn func(hash Hash) (stop bool)

type HashType Uses

type HashType string
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

func (*Header) Marshal Uses

func (hd *Header) Marshal() (b []byte, err error)

Marshal writes a header to bytes

func (*Header) Sum Uses

func (hd *Header) Sum(spec HashSpec) (hash Hash, b []byte, err error)

Sum encodes and creates a hash digest of the header

func (*Header) ToJSON Uses

func (hd *Header) ToJSON() (result string, err error)

ToJSON serializes a header to JSON

func (*Header) Unmarshal Uses

func (hd *Header) Unmarshal(b []byte, hashSize int) (err error)

Unmarshal reads a header from bytes

type HoldReq Uses

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 HoldResp Uses

type HoldResp struct {
    Code      int
    Signature Signature
}

HoldResp holds the signature and code of how a hold request was treated

type Holochain Uses

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 Uses

func NewHolochain(agent Agent, root string, format string, zomes ...Zome) Holochain

NewHolochain creates a new holochain structure with a randomly generated ID and default values

func (*Holochain) Activate Uses

func (h *Holochain) Activate() (err error)

Activate fires up the holochain node, starting node discovery and protocols

func (*Holochain) AddAgentEntry Uses

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 Uses

func (h *Holochain) AddBridgeAsCallee(fromDNA Hash, appData string) (token string, err error)

AddBridgeAsCallee registers a token for allowing bridged calls from some other app and calls bridgeGenesis in any zomes with bridge functions

func (*Holochain) AddBridgeAsCaller Uses

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) AddPeer Uses

func (h *Holochain) AddPeer(pi pstore.PeerInfo) (err error)

AddPeer adds a peer to the peerstore if it passes various checks

func (*Holochain) Agent Uses

func (h *Holochain) Agent() Agent

Agent exposes the agent element

func (*Holochain) AgentHash Uses

func (h *Holochain) AgentHash() (id Hash)

AgentHash returns the hash of the Agent entry

func (*Holochain) AgentTopHash Uses

func (h *Holochain) AgentTopHash() (id Hash)

AgentHash returns the hash of the Agent entry

func (*Holochain) BSget Uses

func (h *Holochain) BSget() (err error)

func (*Holochain) BSpost Uses

func (h *Holochain) BSpost() (err error)

func (*Holochain) BridgeCall Uses

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 Uses

func (h *Holochain) BuildBridgeToCallee(app *BridgeApp) (err error)

BuildBridgeToCallee connects h to a running app specified by BridgeApp that will be the Callee, i.e. the the BridgeCallee

func (*Holochain) BuildBridgeToCaller Uses

func (h *Holochain) BuildBridgeToCaller(app *BridgeApp, port string) (err error)

BuildBridgeToCaller connects h to a running app specified by BridgeApp that will be the Caller, i.e. the the BridgeCaller

func (*Holochain) Call Uses

func (h *Holochain) Call(zomeType string, function string, arguments interface{}, exposureContext string) (result interface{}, err error)

Call executes an exposed function

func (*Holochain) Chain Uses

func (h *Holochain) Chain() (n *Chain)

func (*Holochain) Close Uses

func (h *Holochain) Close()

Close releases the resources associated with a holochain

func (*Holochain) DBPath Uses

func (h *Holochain) DBPath() string

DBPath returns a holochain DB path

func (*Holochain) DHT Uses

func (h *Holochain) DHT() *DHT

DHT exposes the DHT structure

func (*Holochain) DNAHash Uses

func (h *Holochain) DNAHash() (id Hash)

DNAHash returns the hash of the DNA entry which is also the holochain ID

func (*Holochain) DNAPath Uses

func (h *Holochain) DNAPath() string

DNAPath returns a holochain DNA path

func (*Holochain) Debug Uses

func (h *Holochain) Debug(m string)

func (*Holochain) Debugf Uses

func (h *Holochain) Debugf(m string, args ...interface{})

Debugf sends a formatted string to the debug log

func (*Holochain) EncodeDNA Uses

func (h *Holochain) EncodeDNA(writer io.Writer) (err error)

EncodeDNA encodes a holochain's DNA to an io.Writer

func (*Holochain) GenChain Uses

func (h *Holochain) GenChain() (headerHash Hash, err error)

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 Uses

func (h *Holochain) GetBridgeToken(hash Hash) (token string, url string, err error)

GetBridgeToken returns a token given the a hash

func (*Holochain) GetBridges Uses

func (h *Holochain) GetBridges() (bridges []Bridge, err error)

GetBridges returns a list of the active bridges on the holochain

func (*Holochain) GetEntryDef Uses

func (h *Holochain) GetEntryDef(t string) (zome *Zome, d *EntryDef, err error)

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 Uses

func (h *Holochain) GetPrivateEntryDefs() (privateDefs []EntryDef)

func (*Holochain) GetProperty Uses

func (h *Holochain) GetProperty(prop string) (property string, err error)

GetProperty returns the value of a DNA property

func (*Holochain) GetValidationResponse Uses

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) GetZome Uses

func (h *Holochain) GetZome(zName string) (z *Zome, err error)

GetZome returns a zome structure given its name

func (*Holochain) HandleAsyncSends Uses

func (h *Holochain) HandleAsyncSends() (err error)

HandleAsyncSends waits on a channel for asyncronous sends

func (*Holochain) HandlePeerFound Uses

func (h *Holochain) HandlePeerFound(pi pstore.PeerInfo)

implement peer found function for mdns discovery

func (*Holochain) HashSpec Uses

func (h *Holochain) HashSpec() HashSpec

HashSpec exposes the hashSpec structure

func (*Holochain) MakeRibosome Uses

func (h *Holochain) MakeRibosome(t string) (r Ribosome, z *Zome, err error)

MakeRibosome creates a Ribosome object based on the zome type

func (*Holochain) Name Uses

func (h *Holochain) Name() string

func (*Holochain) NewEntry Uses

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) Node Uses

func (h *Holochain) Node() *Node

DHT exposes the Node structure

func (*Holochain) NodeIDStr Uses

func (h *Holochain) NodeIDStr() string

NodeIDStr exposes the agent element

func (*Holochain) Nucleus Uses

func (h *Holochain) Nucleus() (n *Nucleus)

func (*Holochain) Overlap Uses

func (h *Holochain) Overlap(hash Hash) (overlap []peer.ID, err error)

Overlap returns a list of all the nodes that overlap for a given hash

func (*Holochain) Prepare Uses

func (h *Holochain) Prepare() (err error)

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 Uses

func (h *Holochain) PrepareHashType() (err error)

PrepareHashType makes sure the given string is a correct multi-hash and stores the code and length to the Holochain struct

func (*Holochain) Query Uses

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 Uses

func (h *Holochain) RedundancyFactor() int

RedundancyFactor returns the redundancy that was set in the DNA

func (*Holochain) Reset Uses

func (h *Holochain) Reset() (err error)

Reset deletes all chain and dht data and resets data structures

func (*Holochain) RootPath Uses

func (h *Holochain) RootPath() string

RootPath returns a holochain root path

func (*Holochain) Send Uses

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 Uses

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) Sign Uses

func (h *Holochain) Sign(data []byte) (signature Signature, err error)

Sign uses the agent's private key to sign the contents of data

func (*Holochain) StartBackgroundTasks Uses

func (h *Holochain) StartBackgroundTasks()

StartBackgroundTasks sets the various background processes in motion

func (*Holochain) Started Uses

func (h *Holochain) Started() bool

Started returns true if the chain has been gened

func (*Holochain) TaskTicker Uses

func (h *Holochain) TaskTicker(interval time.Duration, fn func(h *Holochain)) chan bool

TaskTicker creates a closure for a holochain task

func (*Holochain) TestPath Uses

func (h *Holochain) TestPath() string

TestPath returns the path to a holochain's test directory

func (*Holochain) Top Uses

func (h *Holochain) Top() (top Hash, err error)

Top returns a hash of top header or err if not yet defined

func (*Holochain) UIPath Uses

func (h *Holochain) UIPath() string

UIPath returns a holochain UI path

func (*Holochain) ValidateAction Uses

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 Uses

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

func (*Holochain) Walk Uses

func (h *Holochain) Walk(fn WalkerFn, entriesToo bool) (err error)

Walk takes the argument fn which must be WalkerFn Every WalkerFn is of the form: func(key *Hash, h *Header, entry interface{}) error

func (*Holochain) World Uses

func (h *Holochain) World() *World

func (*Holochain) ZomePath Uses

func (h *Holochain) ZomePath(z *Zome) string

ZomePath returns the path to the zome dna data @todo sanitize the name value

type JSONEntry Uses

type JSONEntry struct {
    C interface{}
}

JSONEntry is a structure for implementing JSON encoding of Entry content

func (*JSONEntry) Content Uses

func (e *JSONEntry) Content() interface{}

func (*JSONEntry) Marshal Uses

func (e *JSONEntry) Marshal() (b []byte, err error)

func (*JSONEntry) Unmarshal Uses

func (e *JSONEntry) Unmarshal(b []byte) (err error)

type JSONSchemaValidator Uses

type JSONSchemaValidator struct {
    // contains filtered or unexported fields
}

func BuildJSONSchemaValidatorFromFile Uses

func BuildJSONSchemaValidatorFromFile(path string) (validator *JSONSchemaValidator, err error)

func BuildJSONSchemaValidatorFromString Uses

func BuildJSONSchemaValidatorFromString(input string) (validator *JSONSchemaValidator, err error)

func (*JSONSchemaValidator) Validate Uses

func (v *JSONSchemaValidator) Validate(entry interface{}) (err error)

type JSRibosome Uses

type JSRibosome struct {
    // contains filtered or unexported fields
}

JSRibosome holds data needed for the Javascript VM

func (*JSRibosome) BridgeGenesis Uses

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 Uses

func (jsr *JSRibosome) BundleCanceled(reason string) (response string, err error)

BundleCancel calls the app bundleCanceled function

func (*JSRibosome) Call Uses

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 Uses

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 Uses

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 Uses

func (jsr *JSRibosome) Run(code string) (result interface{}, err error)

Run executes javascript code

func (*JSRibosome) RunAsyncSendResponse Uses

func (jsr *JSRibosome) RunAsyncSendResponse(response AppMsg, callback string, callbackID string) (result interface{}, err error)

func (*JSRibosome) Type Uses

func (jsr *JSRibosome) Type() string

Type returns the string value under which this ribosome is registered

func (*JSRibosome) ValidateAction Uses

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 Uses

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 Uses

type LibP2PAgent struct {
    // contains filtered or unexported fields
}

func (*LibP2PAgent) AgentEntry Uses

func (a *LibP2PAgent) AgentEntry(revocation Revocation) (entry AgentEntry, err error)

func (*LibP2PAgent) AgentType Uses

func (a *LibP2PAgent) AgentType() AgentType

func (*LibP2PAgent) EncodePubKey Uses

func (a *LibP2PAgent) EncodePubKey() (b58pk string, err error)

func (*LibP2PAgent) GenKeys Uses

func (a *LibP2PAgent) GenKeys(seed io.Reader) (err error)

func (*LibP2PAgent) Identity Uses

func (a *LibP2PAgent) Identity() AgentIdentity

func (*LibP2PAgent) NodeID Uses

func (a *LibP2PAgent) NodeID() (nodeID peer.ID, nodeIDStr string, err error)

func (*LibP2PAgent) PrivKey Uses

func (a *LibP2PAgent) PrivKey() ic.PrivKey

func (*LibP2PAgent) PubKey Uses

func (a *LibP2PAgent) PubKey() ic.PubKey

func (*LibP2PAgent) SetIdentity Uses

func (a *LibP2PAgent) SetIdentity(id AgentIdentity)
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 LinkQuery Uses

type LinkQuery struct {
    Base       Hash
    T          string
    StatusMask int
}

LinkQuery holds a getLinks query

type LinkQueryResp Uses

type LinkQueryResp struct {
    Links []TaggedHash
}

LinkQueryResp holds response to getLinks query

type LinksEntry Uses

type LinksEntry struct {
    Links []Link
}

LinksEntry holds one or more links

func LinksEntryFromJSON Uses

func LinksEntryFromJSON(j string) (entry LinksEntry, err error)

func (*LinksEntry) ToJSON Uses

func (ae *LinksEntry) ToJSON() (encodedEntry string, err error)

type ListAddReq Uses

type ListAddReq struct {
    ListType    string
    Peers       []string
    WarrantType int
    Warrant     []byte
}

type Logger Uses

type Logger struct {
    Name    string
    Enabled bool
    Format  string

    Prefix      string
    PrefixColor *color.Color
    // contains filtered or unexported fields
}

Logger holds logger configuration

func (*Logger) GetColor Uses

func (h *Logger) GetColor(colorName string) *color.Color

func (*Logger) Log Uses

func (l *Logger) Log(m interface{})

func (*Logger) Logf Uses

func (l *Logger) Logf(m string, args ...interface{})

func (*Logger) New Uses

func (l *Logger) New(w io.Writer) (err error)

func (*Logger) SetPrefix Uses

func (l *Logger) SetPrefix(prefixFormat string)

type Loggers Uses

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 Uses

type Message struct {
    Type MsgType
    Time time.Time
    From peer.ID
    Body interface{}
}

Message represents data that can be sent to node in the network

func (*Message) Decode Uses

func (m *Message) Decode(r io.Reader) (err error)

Decode converts a message from gob format @TODO generalize for other message encoding formats

func (*Message) Encode Uses

func (m *Message) Encode() (data []byte, err error)

Encode codes a message to gob format @TODO generalize for other message encoding formats

func (*Message) Fingerprint Uses

func (m *Message) Fingerprint() (f Hash, err error)

Fingerprint creates a hash of a message

func (Message) String Uses

func (m Message) String() string

String converts a message to a nice string

type MigrateEntry Uses

type MigrateEntry struct {
    Type    string
    DNAHash Hash
    Key     Hash
    Data    string
}

MigrateEntry struct is the record of a chain opening or closing

func MigrateEntryFromJSON Uses

func MigrateEntryFromJSON(j string) (entry MigrateEntry, err error)

func (*MigrateEntry) Def Uses

func (e *MigrateEntry) Def() *EntryDef

@see https://github.com/holochain/holochain-proto/issues/731

func (*MigrateEntry) ToJSON Uses

func (e *MigrateEntry) ToJSON() (encodedEntry string, err error)

type ModAgentOptions Uses

type ModAgentOptions struct {
    Identity   string
    Revocation string
}

type MsgType Uses

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

func (MsgType) String Uses

func (msgType MsgType) String() string

type Node Uses

type Node struct {
    HashAddr peer.ID
    NetAddr  ma.Multiaddr
    // contains filtered or unexported fields
}

Node represents a node in the network

func NewNode Uses

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) Block Uses

func (node *Node) Block(addr peer.ID)

Block adds a peer to the blocklist

func (*Node) Close Uses

func (node *Node) Close() error

Close shuts down the node

func (*Node) Context Uses

func (node *Node) Context() context.Context

Context return node's context

func (*Node) Distance Uses

func (node *Node) Distance(id peer.ID) *big.Int

Distance returns the nodes peer distance to another node for purposes of gossip

func (*Node) EnableMDNSDiscovery Uses

func (n *Node) EnableMDNSDiscovery(h *Holochain, interval time.Duration) (err error)

func (*Node) ExternalAddr Uses

func (n *Node) ExternalAddr() ma.Multiaddr

func (*Node) FindLocal Uses

func (node *Node) FindLocal(id peer.ID) pstore.PeerInfo

FindLocal looks for a peer with a given ID connected to this node and returns its peer info

func (*Node) FindPeer Uses

func (node *Node) FindPeer(ctx context.Context, id peer.ID) (pstore.PeerInfo, error)

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 Uses

func (node *Node) GetClosestPeers(ctx context.Context, key Hash) (<-chan peer.ID, error)

Kademlia 'node lookup' operation. Returns a channel of the K closest peers to the given key

func (*Node) InitBlockedList Uses

func (node *Node) InitBlockedList(list PeerList)

InitBlockedList sets up the blockedlist from a PeerList

func (*Node) IsBlocked Uses

func (node *Node) IsBlocked(addr peer.ID) (ok bool)

IsBlockedListed checks to see if a node is on the blockedlist

func (*Node) NewMessage Uses

func (node *Node) NewMessage(t MsgType, body interface{}) (msg *Message)

NewMessage creates a message from the node with a new current timestamp

func (*Node) Process Uses

func (node *Node) Process() goprocess.Process

Process return node's process

func (*Node) Send Uses

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 Uses

func (node *Node) StartProtocol(h *Holochain, proto int) (err error)

StartProtocol initiates listening for a protocol on the node

func (*Node) Unblock Uses

func (node *Node) Unblock(addr peer.ID)

Unblock removes a peer from the blocklist

type NodeRecord Uses

type NodeRecord struct {
    PeerInfo  pstore.PeerInfo
    PubKey    ic.PubKey
    IsHolding map[Hash]bool
}

NodeRecord stores the necessary information about other nodes in the world model

type Nucleus Uses

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 Uses

func NewNucleus(h *Holochain, dna *DNA) *Nucleus

NewNucleus creates a new Nucleus structure

func (*Nucleus) DNA Uses

func (n *Nucleus) DNA() (dna *DNA)

func (*Nucleus) RunGenesis Uses

func (n *Nucleus) RunGenesis() (err error)

func (*Nucleus) Start Uses

func (n *Nucleus) Start() (err error)

type Package Uses

type Package struct {
    Chain []byte
}

Package holds app specified data needed for validation (wire package)

func MakePackage Uses

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 Uses

type PackagingReq map[string]interface{}

PackagingReq holds a request from an app for data to be included in the validation response

type PeerInfo Uses

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 Uses

type PeerList struct {
    Type    PeerListType
    Records []PeerRecord
}

type PeerListType Uses

type PeerListType string

we also gossip about peers too, keeping lists of different peers e.g. blockedlist etc

type PeerRecord Uses

type PeerRecord struct {
    ID      peer.ID
    Warrant string // evidence, reasons, documentation of why peer is in this list
}

type Progenitor Uses

type Progenitor struct {
    Identity string
    PubKey   []byte
}

Progenitor holds data on the creator of the DNA

type Protocol Uses

type Protocol struct {
    ID       protocol.ID
    Receiver ReceiverFn
}

Protocol encapsulates data for our different protocols

type Put Uses

type Put struct {
    Idx int
    M   Message
}

Put holds a put or link for gossiping

type QueryConstrain Uses

type QueryConstrain struct {
    EntryTypes []string
    Contains   string
    Equals     string
    Matches    string
    Count      int
    Page       int
}

type QueryOptions Uses

type QueryOptions struct {
    Return    QueryReturn
    Constrain QueryConstrain
    Order     QueryOrder
    Bundle    bool
}

type QueryOrder Uses

type QueryOrder struct {
    Ascending bool
}

type QueryResult Uses

type QueryResult struct {
    Header *Header
    Entry  Entry
}

type QueryReturn Uses

type QueryReturn struct {
    Hashes  bool
    Entries bool
    Headers bool
}

type ReceiverFn Uses

type ReceiverFn func(h *Holochain, m *Message) (response interface{}, err error)

type Revocation Uses

type Revocation interface {
    Verify() error
    Marshal() (string, error)
    Unmarshal(string) error
}

type Ribosome Uses

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 Uses

func CreateRibosome(h *Holochain, zome *Zome) (Ribosome, error)

CreateRibosome returns a new Ribosome of the given type

func NewJSRibosome Uses

func NewJSRibosome(h *Holochain, zome *Zome) (n Ribosome, err error)

NewJSRibosome factory function to build a javascript execution environment for a zome

func NewZygoRibosome Uses

func NewZygoRibosome(h *Holochain, zome *Zome) (n Ribosome, err error)

NewZygoRibosome factory function to build a zygo execution environment for a zome

type RibosomeFactory Uses

type RibosomeFactory func(h *Holochain, zome *Zome) (Ribosome, error)

type RoutingTable Uses

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 Uses

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 Uses

func (rt *RoutingTable) Find(id peer.ID) peer.ID

Find a specific peer by ID or return nil

func (*RoutingTable) IsEmpty Uses

func (rt *RoutingTable) IsEmpty() (empty bool)

IsEmpty returns bool

func (*RoutingTable) ListPeers Uses

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 Uses

func (rt *RoutingTable) NearestPeer(hash Hash) peer.ID

NearestPeer returns a single peer that is nearest to the given Hash

func (*RoutingTable) NearestPeers Uses

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 Uses

func (rt *RoutingTable) Print()

Print prints a descriptive statement about the provided RoutingTable

func (*RoutingTable) Remove Uses

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 Uses

func (rt *RoutingTable) Size() int

Size returns the total number of peers in the routing table

func (*RoutingTable) Update Uses

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 Uses

type SchemaValidator interface {
    Validate(interface{}) error
}

SchemaValidator interface for schema validation

type SelfRevocation Uses

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 Uses

func NewSelfRevocation(old, new ic.PrivKey, payload []byte) (rP *SelfRevocation, err error)

func (*SelfRevocation) Marshal Uses

func (r *SelfRevocation) Marshal() (data string, err error)

func (*SelfRevocation) Unmarshal Uses

func (r *SelfRevocation) Unmarshal(data string) (err error)

func (*SelfRevocation) Verify Uses

func (r *SelfRevocation) Verify() (err error)

Verify confirms that a self-revocation is properly signed

type SelfRevocationWarrant Uses

type SelfRevocationWarrant struct {
    Revocation SelfRevocation
}

SelfRevocationWarrant warrants that the first party revoked its own key in favor of the second

func NewSelfRevocationWarrant Uses

func NewSelfRevocationWarrant(revocation *SelfRevocation) (wP *SelfRevocationWarrant, err error)

func (*SelfRevocationWarrant) Decode Uses

func (w *SelfRevocationWarrant) Decode(data []byte) (err error)

func (*SelfRevocationWarrant) Encode Uses

func (w *SelfRevocationWarrant) Encode() (data []byte, err error)

func (*SelfRevocationWarrant) Parties Uses

func (w *SelfRevocationWarrant) Parties() (parties []Hash, err error)

func (*SelfRevocationWarrant) Property Uses

func (w *SelfRevocationWarrant) Property(key string) (value interface{}, err error)

func (*SelfRevocationWarrant) Type Uses

func (w *SelfRevocationWarrant) Type() int

func (*SelfRevocationWarrant) Verify Uses

func (w *SelfRevocationWarrant) Verify(h *Holochain) (err error)

type SendOptions Uses

type SendOptions struct {
    Callback *Callback
    Timeout  int
}

type Service Uses

type Service struct {
    Settings     ServiceConfig
    DefaultAgent Agent
    Path         string
}

A Service is a Holochain service data structure

func Init Uses

func Init(root string, identity AgentIdentity, seed io.Reader) (service *Service, err error)

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 Uses

func LoadService(path string) (service *Service, err error)

LoadService creates a service object from a configuration file

func SetupTestService Uses

func SetupTestService() (d string, s *Service)

func (*Service) Clone Uses

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 Uses

func (s *Service) ConfiguredChains() (chains map[string]*Holochain, err error)

ConfiguredChains returns a list of the configured chains for the given service

func (*Service) GenChain Uses

func (s *Service) GenChain(name string) (h *Holochain, err error)

GenChain adds the genesis entries to a newly cloned or joined chain

func (*Service) InitAppDir Uses

func (service *Service) InitAppDir(root string, encodingFormat string) (err error)

func (*Service) IsConfigured Uses

func (s *Service) IsConfigured(name string) (f string, err error)

IsConfigured checks a directory for correctly set up holochain configuration file

func (*Service) ListChains Uses

func (s *Service) ListChains() (list string)

List chains produces a textual representation of the chains in the .holochain directory

func (*Service) Load Uses

func (s *Service) Load(name string) (h *Holochain, err error)

Load instantiates a Holochain instance from disk

func (*Service) MakeAppPackage Uses

func (service *Service) MakeAppPackage(h *Holochain) (data []byte, err error)

MakeAppPackage creates a package blob from a given holochain

func (*Service) MakeTestingApp Uses

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 Uses

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 Uses

type ServiceConfig struct {
    DefaultPeerModeAuthor  bool
    DefaultPeerModeDHTNode bool
    DefaultBootstrapServer string
    DefaultEnableMDNS      bool
    DefaultEnableNATUPnP   bool
}

ServiceConfig holds the service settings

func (*ServiceConfig) Validate Uses

func (c *ServiceConfig) Validate() (err error)

Validate validates settings values

type Signature Uses

type Signature struct {
    S []byte
}

func SignatureFromB58String Uses

func SignatureFromB58String(encoded string) (sig Signature)

SignatureFromB58String encodes a signature as a b58string

func (Signature) B58String Uses

func (sig Signature) B58String() (result string)

B58String encodes a signature as a b58string

func (Signature) Equal Uses

func (sig1 Signature) Equal(sig2 Signature) bool

Equal tests signature equality

type TaggedHash Uses

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 Uses

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 Uses

func LoadTestConfig(dir string) (config *TestConfig, err error)

LoadTestConfig unmarshals test json data

type TestData Uses

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 Uses

type TestFixtures struct {
    Agents []AgentFixture
}

TestFixtures defines data needed to run tests

type TestSet Uses

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

func LoadTestFile Uses

func LoadTestFile(dir string, file string) (tests TestSet, err error)

LoadTestFile unmarshals test json data

type ValidateQuery Uses

type ValidateQuery struct {
    H Hash
}

ValidateQuery holds the data from a validation query on the Source protocol

type ValidateResponse Uses

type ValidateResponse struct {
    Type    string
    Header  Header
    Entry   GobEntry
    Package Package
}

ValidateResponse holds the response to committing validates (PUT/MOD/DEL)

type ValidatingAction Uses

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 Uses

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 Uses

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 WalkerFn Uses

type WalkerFn func(key *Hash, header *Header, entry Entry) error

WalkerFn a function type for call Walk

type Warrant Uses

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

func DecodeWarrant Uses

func DecodeWarrant(warrantType int, data []byte) (w Warrant, err error)

type World Uses

type World struct {
    // contains filtered or unexported fields
}

World holds the data of a nodes' world model

func NewWorld Uses

func NewWorld(me peer.ID, ht HashTable, logger *Logger) *World

NewWorld creates and empty world model

func (*World) AddNode Uses

func (world *World) AddNode(pi pstore.PeerInfo, pubKey ic.PubKey) (err error)

AddNode adds a node to the world model

func (*World) AllNodes Uses

func (world *World) AllNodes() (nodes []peer.ID, err error)

AllNodes returns a list of all the nodes in the world model.

func (*World) GetNodeRecord Uses

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) IsHolding Uses

func (world *World) IsHolding(ID peer.ID, hash Hash) (holding bool, err error)

IsHolding returns whether a node is holding a particular hash

func (*World) Responsible Uses

func (world *World) Responsible() (entries []Hash, err error)

Responsible returns a list of all the entries I'm responsible for holding

func (*World) SetNodeHolding Uses

func (world *World) SetNodeHolding(ID peer.ID, hash Hash) (err error)

SetNodeHolding marks a node as holding a particular hash

func (*World) UpdateResponsible Uses

func (world *World) UpdateResponsible(hash Hash, redundancy int) (responsible bool, err error)

UpdateResponsible calculates the list of nodes believed to be responsible for a given hash note that if redundancy is 0 the assumption is that all nodes are responsible

type Zome Uses

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 Uses

func (zome *Zome) CodeFileName() string

func (*Zome) GetEntryDef Uses

func (z *Zome) GetEntryDef(entryName string) (e *EntryDef, err error)

GetEntryDef returns the entry def structure

func (*Zome) GetFunctionDef Uses

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 Uses

func (z *Zome) GetPrivateEntryDefs() (privateDefs []EntryDef)

func (*Zome) MakeRibosome Uses

func (zome *Zome) MakeRibosome(h *Holochain) (r Ribosome, err error)

type ZomeFile Uses

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 Uses

type ZygoRibosome struct {
    // contains filtered or unexported fields
}

ZygoRibosome holds data needed for the Zygo VM

func (*ZygoRibosome) BridgeGenesis Uses

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 Uses

func (z *ZygoRibosome) BundleCanceled(reason string) (response string, err error)

BundleCancel calls the app bundleCanceled function

func (*ZygoRibosome) Call Uses

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 Uses

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 Uses

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 Uses

func (z *ZygoRibosome) Run(code string) (result interface{}, err error)

Run executes zygo code

func (*ZygoRibosome) RunAsyncSendResponse Uses

func (z *ZygoRibosome) RunAsyncSendResponse(response AppMsg, callback string, callbackID string) (result interface{}, err error)

func (*ZygoRibosome) Type Uses

func (z *ZygoRibosome) Type() string

Type returns the string value under which this ribosome is registered

func (*ZygoRibosome) ValidateAction Uses

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 Uses

func (z *ZygoRibosome) ValidatePackagingRequest(action ValidatingAction, def *EntryDef) (req PackagingReq, err error)

ValidatePackagingRequest calls the app for a validation packaging request for an action

Directories

PathSynopsis
apptest
cmd
cmd/bs
cmd/hcadmin
cmd/hcd
cmd/hcdev
hash
peerqueue
ui

Package holochain imports 61 packages (graph). Updated 2018-09-26. Refresh now. Tools for package owners.