providechainpoint

package module
v0.0.0-...-ad02d0a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2019 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

provide-chainpoint

Provide chainpoint integration leveraging chainpoint.go

initial provide-chainpoint architecture diagram

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log = logger.NewLogger("provide-chainpoint", getLogLevel(), true)

Log global

Functions

func ImmortalizeHashes

func ImmortalizeHashes(provideID string, hashes []*[]byte) error

ImmortalizeHashes places an array of hashes (represented as *[]byte at this point) on a buffered channel managed by a chainpoint daemon instance. In architecture.svg, this method represents the "hash subject" entrypoint and a typical use-case is upon receipt of a blockheader.

The provideID is typically-- i.e., when this method is called by the initial Provide platform implementation-- the unique identifier of a network on the Provide platform. Other implementations can define their own business rules for what provideID actually represents at runtime, but it will be used to create a hash with each of the given hashes.

func RunChainpointDaemon

func RunChainpointDaemon(bufferSize int, flushIntervalMillis, proofIntervalMillis uint) error

RunChainpointDaemon initializes and starts a new chainpoint daemon and aggregates hashes on a buffered channel until the channel is full or a configured timeout expires, at which point the entire buffer is flushed by way of provide.SubmitHashes.

Upon successful flushing of the buffer the related in-flight NATS messages are ACK'd. Upon timeout of an in-flight NATS message (i.e., a message delivered using the chainpoint.hash subject), the message will be attempted for redelivery. There is not currently a dead-letter strategy associated with chainpoint daemons (i.e., messages will be retried forever unless removed from the NATS streaming broker). A dead-letter queue will be considered but needs additional discussion.

This method returns an error if there is already a chainpoint usage daemon running in the parent golang process (chainpoint daemon is currently singleton-per-process).

Types

type Node

type Node struct {
	PublicURI string `json:"public_uri"`
}

Node represents a chainpoint node

type NodeList

type NodeList []*Node

NodeList array of Node pointers

func GetNodes

func GetNodes() (*NodeList, error)

GetNodes retrieves a list of 25 random Chainpoint Nodes.

type ProofBody

type ProofBody struct {
	Anchors    []interface{} `json:"anchors_complete"`
	HashIDNode string        `json:"hash_id_node"`
	Proof      interface{}   `json:"proof"`
}

ProofBody

func GetProofs

func GetProofs(proofHandles []ProofHandle) ([]ProofBody, error)

GetProofs function accepts a list of Proof Handles and will retrieve their corresponding Chainpoint Proofs. This function includes the subtle optimization of grouping Proof Handles by Chainpoint Node PublicURI's and will issue one HTTP GET request with an embedded header value consisting of a comma-delimited string of hashIdNode values dictating which Proofs need to be resolved and returned to the requestor.

type ProofHandle

type ProofHandle struct {
	Hash       string `json:"hash"`
	HashIDNode string `json:"hashIdNode"`
	URI        string `json:"URI"`
}

ProofHandle

func SubmitHashes

func SubmitHashes(hashes [][]byte, nodes *NodeList) ([]ProofHandle, error)

SubmitHashes will submit a list of hashes to every Chainpoint Node provided to it via the function's second argument `nodes` of type `NodeList`. Submitting to multiple Chainpoint Nodes to achieve your required level of redundancy is advised. Only a single Chainpoint Proof is required to attest the existence of your data.

type VerifiedProofs

type VerifiedProofs []struct {
	ProofIndex          int       `json:"proof_index"`
	Hash                string    `json:"hash"`
	HashIDNode          string    `json:"hash_id_node"`
	HashSubmittedNodeAt time.Time `json:"hash_submitted_node_at"`
	HashIDCore          string    `json:"hash_id_core"`
	HashSubmittedCoreAt time.Time `json:"hash_submitted_core_at"`
	Anchors             []struct {
		Branch string `json:"branch"`
		Type   string `json:"type"`
		Valid  bool   `json:"valid"`
	} `json:"anchors"`
	Status string `json:"status"`
}

VerifiedProofs as returned by chainpoint

func VerifyProofs

func VerifyProofs(proofs []string) (VerifiedProofs, error)

VerifyProofs accepts a list of base64 encode strings that will be submitted to any Chainpoint Node for verification. The verification process will perform the required cryptorgraphic operations for both `cal` and `btc` branches to verify the integrity of the Chainpoint Proof(s) that have been submitted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址