Documentation ¶
Index ¶
- type Chain
- func (m *Chain) AddEntry(hash []byte, unique bool) error
- func (c *Chain) Commit() error
- func (c *Chain) Element(index uint64) values.Value[[]byte]
- func (c *Chain) ElementIndex(hash []byte) values.Value[uint64]
- func (m *Chain) Entries(begin, end int64) ([][]byte, error)
- func (m *Chain) Entry(element int64) ([]byte, error)
- func (c *Chain) Head() values.Value[*State]
- func (m *Chain) IndexOf(hash []byte) (int64, error)
- func (c *Chain) IsDirty() bool
- func (c *Chain) Key() *record.Key
- func (c *Chain) MarkFreq() int64
- func (c *Chain) MarkMask() int64
- func (c *Chain) MarkPower() int64
- func (c *Chain) Name() string
- func (c *Chain) Receipt(from, to int64) (*Receipt, error)
- func (c *Chain) Resolve(key *record.Key) (record.Record, *record.Key, error)
- func (m *Chain) StateAt(element int64) (ms *State, err error)
- func (c *Chain) States(index uint64) values.Value[*State]
- func (c *Chain) Type() ChainType
- func (c *Chain) Walk(opts record.WalkOptions, fn record.WalkFunc) error
- type ChainIndex
- func (x *ChainIndex) Append(key *record.Key, index uint64) error
- func (c *ChainIndex) Commit() error
- func (x *ChainIndex) Find(target *record.Key) ChainSearchResult
- func (c *ChainIndex) IsDirty() bool
- func (c *ChainIndex) Key() *record.Key
- func (x *ChainIndex) Last() (*record.Key, uint64, error)
- func (c *ChainIndex) Resolve(key *record.Key) (record.Record, *record.Key, error)
- func (c *ChainIndex) Walk(opts record.WalkOptions, fn record.WalkFunc) error
- type ChainSearchResult
- type ChainSearchResult2
- type ChainType
- type Hasher
- func (h *Hasher) AddBigInt(v *big.Int)
- func (h *Hasher) AddBool(v bool)
- func (h *Hasher) AddBytes(v []byte)
- func (h *Hasher) AddDuration(v time.Duration)
- func (h *Hasher) AddEnum(v interface{ ... })
- func (h *Hasher) AddHash(v *[32]byte)
- func (h *Hasher) AddHash2(v [32]byte)
- func (h *Hasher) AddInt(v int64)
- func (h *Hasher) AddString(v string)
- func (h *Hasher) AddTime(v time.Time)
- func (h *Hasher) AddTxID(v *url.TxID)
- func (h *Hasher) AddUint(v uint64)
- func (h *Hasher) AddUrl(v *url.URL)
- func (h *Hasher) AddUrl2(v *url.URL)
- func (h *Hasher) AddValue(v interface{ ... })
- func (h Hasher) MerkleHash() []byte
- func (h Hasher) Receipt(start, anchor int) *Receipt
- type Receipt
- func (r *Receipt) Combine(receipts ...*Receipt) (*Receipt, error)
- func (r *Receipt) Contains(other *Receipt) bool
- func (v *Receipt) Copy() *Receipt
- func (v *Receipt) CopyAsInterface() interface{}
- func (v *Receipt) Equal(u *Receipt) bool
- func (v *Receipt) IsValid() error
- func (v *Receipt) MarshalBinary() ([]byte, error)
- func (v *Receipt) MarshalJSON() ([]byte, error)
- func (v *Receipt) UnmarshalBinary(data []byte) error
- func (v *Receipt) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *Receipt) UnmarshalJSON(data []byte) error
- func (r *Receipt) Validate(opts *ValidateOptions) bool
- type ReceiptEntry
- func (v *ReceiptEntry) Copy() *ReceiptEntry
- func (v *ReceiptEntry) CopyAsInterface() interface{}
- func (v *ReceiptEntry) Equal(u *ReceiptEntry) bool
- func (v *ReceiptEntry) IsValid() error
- func (v *ReceiptEntry) MarshalBinary() ([]byte, error)
- func (v *ReceiptEntry) MarshalJSON() ([]byte, error)
- func (v *ReceiptEntry) UnmarshalBinary(data []byte) error
- func (v *ReceiptEntry) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *ReceiptEntry) UnmarshalJSON(data []byte) error
- type ReceiptList
- func (v *ReceiptList) Copy() *ReceiptList
- func (v *ReceiptList) CopyAsInterface() interface{}
- func (v *ReceiptList) Equal(u *ReceiptList) bool
- func (r *ReceiptList) Included(entry []byte) bool
- func (v *ReceiptList) IsValid() error
- func (v *ReceiptList) MarshalBinary() ([]byte, error)
- func (v *ReceiptList) MarshalJSON() ([]byte, error)
- func (v *ReceiptList) UnmarshalBinary(data []byte) error
- func (v *ReceiptList) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *ReceiptList) UnmarshalJSON(data []byte) error
- func (r *ReceiptList) Validate(opts *ValidateOptions) bool
- type State
- func (m *State) AddEntry(hash_ []byte)
- func (m *State) Anchor() (anchor []byte)
- func (v *State) Copy() *State
- func (v *State) CopyAsInterface() interface{}
- func (m *State) Equal(m2 *State) (isEqual bool)
- func (m *State) MarshalBinary() ([]byte, error)
- func (v *State) MarshalJSON() ([]byte, error)
- func (m *State) UnmarshalBinary(data []byte) error
- func (m *State) UnmarshalBinaryFrom(rd io.Reader) error
- func (v *State) UnmarshalJSON(data []byte) error
- type ValidateOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func (*Chain) AddEntry ¶
AddEntry adds a Hash to the Chain controlled by the ChainManager. If unique is true, the hash will not be added if it is already in the chain.
func (*Chain) Entries ¶
Entries returns the list of hashes with indexes indicated by range: (begin,end) begin must be before or equal to end. The hash with index begin upto but not including end are the hashes returned. Indexes are zero based, so the first hash in the State is at 0
type ChainIndex ¶
type ChainIndex struct {
// contains filtered or unexported fields
}
func NewChainIndex ¶
NewChainIndex constructs a new ChainIndex data model object. ChainIndex supports appending keys in ascending order, e.g. as the chain grows. It does not allow adding keys that would sort before or between existing items.
func (*ChainIndex) Append ¶
func (x *ChainIndex) Append(key *record.Key, index uint64) error
Append appends a (key, index) entry into the chain index. Append returns an error if the key does not come after all other entries.
func (*ChainIndex) Commit ¶
func (c *ChainIndex) Commit() error
func (*ChainIndex) Find ¶
func (x *ChainIndex) Find(target *record.Key) ChainSearchResult
Find searches for the closest index entry to the target.
func (*ChainIndex) IsDirty ¶
func (c *ChainIndex) IsDirty() bool
func (*ChainIndex) Key ¶
func (c *ChainIndex) Key() *record.Key
func (*ChainIndex) Last ¶
func (x *ChainIndex) Last() (*record.Key, uint64, error)
Last returns the last index entry.
func (*ChainIndex) Walk ¶
func (c *ChainIndex) Walk(opts record.WalkOptions, fn record.WalkFunc) error
type ChainSearchResult ¶
type ChainSearchResult interface { // Before returns the target entry if the match was exact, the entry before // the target if one exists, or an error result. Before() ChainSearchResult2 // Exact returns the target entry if the match was exact, or an error // result. Exact() ChainSearchResult2 // After returns the target entry if the match was exact, the entry after // the target if one exists, or an error result. After() ChainSearchResult2 }
type ChainSearchResult2 ¶
type ChainType ¶
type ChainType uint64
ChainType is the type of a chain belonging to an account.
const ChainTypeAnchor ChainType = 2
ChainTypeAnchor holds chain anchors.
const ChainTypeIndex ChainType = 4
ChainTypeIndex indexes other chains.
const ChainTypeTransaction ChainType = 1
ChainTypeTransaction holds transaction hashes.
const ChainTypeUnknown ChainType = 0
ChainTypeUnknown is used when the chain type is not known.
func ChainTypeByName ¶
ChainTypeByName returns the named Chain Type.
func (ChainType) GetEnumValue ¶
GetEnumValue returns the value of the Chain Type
func (ChainType) MarshalJSON ¶
MarshalJSON marshals the Chain Type to JSON as a string.
func (*ChainType) SetEnumValue ¶
SetEnumValue sets the value. SetEnumValue returns false if the value is invalid.
func (*ChainType) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Chain Type from JSON as a string.
type Receipt ¶
type Receipt struct { // Start is the entry for which we want a proof. Start []byte `json:"start,omitempty" form:"start" query:"start" validate:"required"` StartIndex int64 `json:"startIndex,omitempty" form:"startIndex" query:"startIndex" validate:"required"` // End is the entry at the index where the anchor was created. End []byte `json:"end,omitempty" form:"end" query:"end" validate:"required"` EndIndex int64 `json:"endIndex,omitempty" form:"endIndex" query:"endIndex" validate:"required"` // Anchor is the root expected once all nodes are applied. Anchor []byte `json:"anchor,omitempty" form:"anchor" query:"anchor" validate:"required"` // Entries is the list of hashes to apply to create an anchor. Entries []*ReceiptEntry `json:"entries,omitempty" form:"entries" query:"entries" validate:"required"` // contains filtered or unexported fields }
func (*Receipt) Combine ¶
Combine Take a 2nd receipt, attach it to a root receipt, and return the resulting receipt. The idea is that if this receipt is anchored into another chain, Then we can create a receipt that proves the element in this receipt all the way down to an anchor in the root receipt. Note that both this receipt and the root receipt are expected to be good.
func (*Receipt) Contains ¶
Contains returns true if the 2nd receipt is equal to or contained within the first.
func (*Receipt) CopyAsInterface ¶
func (v *Receipt) CopyAsInterface() interface{}
func (*Receipt) MarshalBinary ¶
func (*Receipt) MarshalJSON ¶
func (*Receipt) UnmarshalBinary ¶
func (*Receipt) UnmarshalJSON ¶
func (*Receipt) Validate ¶
func (r *Receipt) Validate(opts *ValidateOptions) bool
Validate Take a receipt and validate that the element hash progresses to the Merkle Dag Root hash (MDRoot) in the receipt
type ReceiptEntry ¶
type ReceiptEntry struct { Right bool `json:"right,omitempty" form:"right" query:"right" validate:"required"` Hash []byte `json:"hash,omitempty" form:"hash" query:"hash" validate:"required"` // contains filtered or unexported fields }
func (*ReceiptEntry) Copy ¶
func (v *ReceiptEntry) Copy() *ReceiptEntry
func (*ReceiptEntry) CopyAsInterface ¶
func (v *ReceiptEntry) CopyAsInterface() interface{}
func (*ReceiptEntry) Equal ¶
func (v *ReceiptEntry) Equal(u *ReceiptEntry) bool
func (*ReceiptEntry) IsValid ¶
func (v *ReceiptEntry) IsValid() error
func (*ReceiptEntry) MarshalBinary ¶
func (v *ReceiptEntry) MarshalBinary() ([]byte, error)
func (*ReceiptEntry) MarshalJSON ¶
func (v *ReceiptEntry) MarshalJSON() ([]byte, error)
func (*ReceiptEntry) UnmarshalBinary ¶
func (v *ReceiptEntry) UnmarshalBinary(data []byte) error
func (*ReceiptEntry) UnmarshalBinaryFrom ¶
func (v *ReceiptEntry) UnmarshalBinaryFrom(rd io.Reader) error
func (*ReceiptEntry) UnmarshalJSON ¶
func (v *ReceiptEntry) UnmarshalJSON(data []byte) error
type ReceiptList ¶
type ReceiptList struct { // MerkleState merkle.State at the beginning of the list. MerkleState *State `json:"merkleState,omitempty" form:"merkleState" query:"merkleState" validate:"required"` Elements [][]byte `json:"elements,omitempty" form:"elements" query:"elements" validate:"required"` Receipt *Receipt `json:"receipt,omitempty" form:"receipt" query:"receipt" validate:"required"` ContinuedReceipt *Receipt `json:"continuedReceipt,omitempty" form:"continuedReceipt" query:"continuedReceipt" validate:"required"` // contains filtered or unexported fields }
func GetReceiptList ¶
func GetReceiptList(manager *Chain, Start int64, End int64) (r *ReceiptList, err error)
GetReceiptList Given a merkle tree with a start point and an end point, create a ReceiptList for all the elements from the start hash to the end hash, inclusive.
func NewReceiptList ¶
func NewReceiptList() *ReceiptList
NewReceiptList Return a new ReceiptList with at least a MerkleState initialized
func (*ReceiptList) Copy ¶
func (v *ReceiptList) Copy() *ReceiptList
func (*ReceiptList) CopyAsInterface ¶
func (v *ReceiptList) CopyAsInterface() interface{}
func (*ReceiptList) Equal ¶
func (v *ReceiptList) Equal(u *ReceiptList) bool
func (*ReceiptList) Included ¶
func (r *ReceiptList) Included(entry []byte) bool
Included Tests an entry for inclusion in the given ReceiptList Note that while a ReceiptList proves inclusion in a Merkle Tree, and the fact that the list of elements proceed in order up to and including the anchor point, the ReceiptList does not necessarily prove the indices of the elements in the Merkle Tree. This could be solved by salting Receipts with the index of the hash at the anchor point.
func (*ReceiptList) IsValid ¶
func (v *ReceiptList) IsValid() error
func (*ReceiptList) MarshalBinary ¶
func (v *ReceiptList) MarshalBinary() ([]byte, error)
func (*ReceiptList) MarshalJSON ¶
func (v *ReceiptList) MarshalJSON() ([]byte, error)
func (*ReceiptList) UnmarshalBinary ¶
func (v *ReceiptList) UnmarshalBinary(data []byte) error
func (*ReceiptList) UnmarshalBinaryFrom ¶
func (v *ReceiptList) UnmarshalBinaryFrom(rd io.Reader) error
func (*ReceiptList) UnmarshalJSON ¶
func (v *ReceiptList) UnmarshalJSON(data []byte) error
func (*ReceiptList) Validate ¶
func (r *ReceiptList) Validate(opts *ValidateOptions) bool
Validate Take a receipt and validate that the element hash progresses to the Merkle Dag Root hash (MDRoot) in the receipt
type State ¶
type State struct { // Count is the count of hashes added to the tree. Count int64 `json:"count,omitempty" form:"count" query:"count" validate:"required"` // Pending is the hashes that represent the left edge of the tree. Pending [][]byte `json:"pending,omitempty" form:"pending" query:"pending" validate:"required"` // HashList is the hashes added to the tree. HashList [][]byte `json:"hashList,omitempty" form:"hashList" query:"hashList" validate:"required"` }
func (*State) Anchor ¶
Anchor Compute the Merkle Directed Acyclic Graph (Merkle DAG or ChainHead) for the ChainHead at this point We take any trailing hashes in ChainHead, hash them up and combine to create the Merkle Dag Root. Getting the closing ListMDRoot is non-destructive, which is useful for some use cases.
Returns a nil if the MerkleSate is empty.
func (*State) CopyAsInterface ¶
func (v *State) CopyAsInterface() interface{}
func (*State) MarshalBinary ¶
func (*State) MarshalJSON ¶
func (*State) UnmarshalBinary ¶
func (*State) UnmarshalJSON ¶
type ValidateOptions ¶
type ValidateOptions struct {
Relaxed bool
}