attorney

package
v0.0.0-...-94102d9 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	VoidType byte = iota
	JoinNetworkType
	UpdateInfoType
	GrantPowerOfAttorneyType
	RevokePowerOfAttorneyType
	Invalid
)

Variables

View Source
var AxeProtocolCode = [4]byte{1, 0, 0, 0}

Functions

func GetHashes

func GetHashes(data []byte) []crypto.Hash

func GetTokens

func GetTokens(data []byte) []crypto.Token

func IsAxeNonVoid

func IsAxeNonVoid(action []byte) bool

iisAxeNonVoid checks if a byte array has the header of an axé action different from the void action. It does not try to parse the instruction, so there is no guarantee that the byte array is a valid axé action.

func Kind

func Kind(data []byte) byte

func NewFileHashVaultFromBytes

func NewFileHashVaultFromBytes(filePath, name string, data []byte) *hashVault

func NewHashVault

func NewHashVault(name string, epoch uint64, bitsForBucket int64, dataPath string) *hashVault

func NewMemoryHashVaultFromBytes

func NewMemoryHashVaultFromBytes(name string, data []byte) *hashVault

func NewStateFromBytes

func NewStateFromBytes(datapath string) social.StateFromBytes[*Mutations, *MutatingState]

Types

type ActionValidator

type ActionValidator interface {
	Epoch() uint64
	HasCaption(crypto.Hash) bool
	HasMember(crypto.Hash) bool
	SetNewMember(crypto.Hash, crypto.Hash) bool
	PowerOfAttorney(crypto.Hash) bool
	SetNewGrantPower(crypto.Hash) bool
	SetNewRevokePower(crypto.Hash) bool
}

type GrantPowerOfAttorney

type GrantPowerOfAttorney struct {
	Epoch       uint64
	Author      crypto.Token
	Attorney    crypto.Token
	Fingerprint []byte
	Signature   crypto.Signature
}

func ParseGrantPowerOfAttorney

func ParseGrantPowerOfAttorney(data []byte) *GrantPowerOfAttorney

func (*GrantPowerOfAttorney) Kind

func (g *GrantPowerOfAttorney) Kind() byte

func (*GrantPowerOfAttorney) Serialize

func (g *GrantPowerOfAttorney) Serialize() []byte

func (*GrantPowerOfAttorney) Sign

func (*GrantPowerOfAttorney) Tokens

func (g *GrantPowerOfAttorney) Tokens() []crypto.Token

func (*GrantPowerOfAttorney) Validate

func (g *GrantPowerOfAttorney) Validate(v ActionValidator) bool

type JoinNetwork

type JoinNetwork struct {
	Epoch     uint64
	Author    crypto.Token
	Handle    string
	Details   string
	Signature crypto.Signature
}

func ParseJoinNetwork

func ParseJoinNetwork(data []byte) *JoinNetwork

func (*JoinNetwork) Kind

func (j *JoinNetwork) Kind() byte

func (*JoinNetwork) Serialize

func (j *JoinNetwork) Serialize() []byte

func (*JoinNetwork) Sign

func (j *JoinNetwork) Sign(key crypto.PrivateKey)

func (*JoinNetwork) Tokens

func (j *JoinNetwork) Tokens() []crypto.Token

func (*JoinNetwork) Validate

func (j *JoinNetwork) Validate(v ActionValidator) bool

type KeyExchange

type KeyExchange struct {
	Epoch     uint64
	Author    crypto.Token
	To        crypto.Token
	Ephemeral crypto.Token
	Secret    []byte
	Attorney  crypto.Token
}

type MutatingState

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

func (*MutatingState) HasHandle

func (s *MutatingState) HasHandle(handle string) bool

func (*MutatingState) HasMember

func (s *MutatingState) HasMember(token crypto.Token) bool

func (*MutatingState) Mutations

func (m *MutatingState) Mutations() *Mutations

func (*MutatingState) PowerOfAttorney

func (s *MutatingState) PowerOfAttorney(token, attorney crypto.Token) bool

func (*MutatingState) SetNewGrantPower

func (s *MutatingState) SetNewGrantPower(token, attorney crypto.Token) bool

func (*MutatingState) SetNewMember

func (s *MutatingState) SetNewMember(token crypto.Token, handle string) bool

func (*MutatingState) SetNewRevokePower

func (s *MutatingState) SetNewRevokePower(token, attorney crypto.Token) bool

func (*MutatingState) Validate

func (v *MutatingState) Validate(data []byte) bool

type Mutations

type Mutations struct {
	GrantPower  map[crypto.Hash]struct{}
	RevokePower map[crypto.Hash]struct{}
	NewMembers  map[crypto.Hash]struct{}
	NewCaption  map[crypto.Hash]struct{}
}

func NewMutations

func NewMutations() *Mutations

func (*Mutations) HasCaption

func (m *Mutations) HasCaption(hash crypto.Hash) bool

func (*Mutations) HasGrantPower

func (m *Mutations) HasGrantPower(hash crypto.Hash) bool

func (*Mutations) HasMember

func (m *Mutations) HasMember(hash crypto.Hash) bool

func (*Mutations) HasRevokePower

func (m *Mutations) HasRevokePower(hash crypto.Hash) bool

func (*Mutations) Merge

func (m *Mutations) Merge(others ...*Mutations) *Mutations

type RevokePowerOfAttorney

type RevokePowerOfAttorney struct {
	Epoch     uint64
	Author    crypto.Token
	Attorney  crypto.Token
	Signature crypto.Signature
}

func ParseRevokePowerOfAttorney

func ParseRevokePowerOfAttorney(data []byte) *RevokePowerOfAttorney

func (*RevokePowerOfAttorney) Kind

func (r *RevokePowerOfAttorney) Kind() byte

func (*RevokePowerOfAttorney) Serialize

func (r *RevokePowerOfAttorney) Serialize() []byte

func (*RevokePowerOfAttorney) Sign

func (*RevokePowerOfAttorney) Tokens

func (r *RevokePowerOfAttorney) Tokens() []crypto.Token

func (*RevokePowerOfAttorney) Validate

type State

type State struct {
	Members   *hashVault
	Captions  *hashVault
	Attorneys *hashVault
}

func NewGenesisState

func NewGenesisState(dataPath string) *State

func StateFromBytes

func StateFromBytes(data []byte) *State

func (*State) Checksum

func (s *State) Checksum() crypto.Hash

func (*State) ChecksumPoint

func (s *State) ChecksumPoint() crypto.Hash

ChecksumHash returns the hash of the checksum of the state.

func (*State) Clone

func (s *State) Clone() chan social.Stateful[*Mutations, *MutatingState]

Clone creates a copy of the state by cloning the underlying papirus hashtable stores.

func (*State) CloneAsync

func (s *State) CloneAsync() chan *State

CloneAsync starts a jobe to cloning the underlying hashtable stores. Returns a channel to a state object.

func (*State) HasHandle

func (s *State) HasHandle(handle string) bool

func (*State) HasMember

func (s *State) HasMember(token crypto.Token) bool

func (*State) Incorporate

func (s *State) Incorporate(mutations *Mutations)

func (*State) PowerOfAttorney

func (s *State) PowerOfAttorney(token, attorney crypto.Token) bool

func (*State) Recover

func (s *State) Recover() error

func (*State) Serialize

func (s *State) Serialize() []byte

func (*State) Shutdown

func (s *State) Shutdown()

func (*State) Validator

func (s *State) Validator(mutations ...*Mutations) *MutatingState

type UpdateInfo

type UpdateInfo struct {
	Epoch     uint64
	Author    crypto.Token
	Details   string
	Signer    crypto.Token
	Signature crypto.Signature
}

func ParseUpdateInfo

func ParseUpdateInfo(data []byte) *UpdateInfo

func (*UpdateInfo) Kind

func (u *UpdateInfo) Kind() byte

func (*UpdateInfo) Serialize

func (u *UpdateInfo) Serialize() []byte

func (*UpdateInfo) Sign

func (u *UpdateInfo) Sign(pk crypto.PrivateKey)

func (*UpdateInfo) Tokens

func (u *UpdateInfo) Tokens() []crypto.Token

func (*UpdateInfo) Validate

func (u *UpdateInfo) Validate(v ActionValidator) bool

type Void

type Void struct {
	Epoch     uint64
	Protocol  uint32
	Author    crypto.Token
	Data      []byte
	Signer    crypto.Token
	Signature crypto.Signature
}

func ParseVoid

func ParseVoid(data []byte) *Void

func (*Void) Kind

func (v *Void) Kind() byte

func (*Void) Serialize

func (v *Void) Serialize() []byte

func (*Void) Sign

func (v *Void) Sign(pk crypto.PrivateKey)

func (*Void) Tokens

func (g *Void) Tokens() []crypto.Token

func (*Void) Validate

func (void *Void) Validate(v ActionValidator) bool

Jump to

Keyboard shortcuts

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