model

package
v0.0.0-...-822dead Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProposeTax               = "ProposeTax"
	ProposeTaxVar            = "ProposeTaxVar"
	ProposeTaxRevenueTarget  = "ProposeTaxRevenueTarget"
	ProposeTaxType           = "ProposeTaxType"
	ProposeNewVariable       = "ProposeNewVariable"
	ProposeCreateAccount     = "ProposeCreateAccount"
	ProposeAccountPermission = "ProposeAccountPermission"
	ProposeNewRole           = "ProposeNewRole"
	ProposeAddPermission     = "ProposeAddPermission"
)

Constitutional Proposition predicates

View Source
const (
	GlobalTransactionTax = "GlobalTransactionTax"
	BytesTax             = "BytesTax"
)

Tax types

View Source
const (
	UnitIntervalType = "UnitIntervalValue"
	CategoryType     = "CategoryVariable"
	IntegerType      = "IntegerVariable"
)

Variable types

View Source
const (
	VoteGrantClaim             = "VoteGrantClaim"
	VoteRevokeClaim            = "VoteRevokeClaim"
	VoteGrantPermissionToRole  = "VoteGrantPermissionToRole"
	VoteRevokePermissionToRole = "VoteRevokePermissionToRole"
	VoteVariableValue          = "VoteVariableValue"
	VoteAmendment              = "VoteAmendment"
)
View Source
const (
	Citizen            = "Citizen"
	CitizenshipOfficer = "CitizenshipOfficer"
)
View Source
const (
	DtDiffEval = 12 // window size (# of blocks) to compute pow difficulty
	PercentRot = 0.67
)
View Source
const ClaimExpiry = 1

Variables

View Source
var AvailableRole = []string{
	Citizen,
	CitizenshipOfficer,
}
View Source
var AvailableTaxType = []string{GlobalTransactionTax, BytesTax}
View Source
var AvailableVariableTax = []string{UnitIntervalType, CategoryType, IntegerType}
View Source
var InstallAmendment = map[string]func(predicate *Rule, cratos *Cratos){
	ProposeTax:               installTax,
	ProposeTaxVar:            installTaxVar,
	ProposeTaxRevenueTarget:  installTaxRevenueTarget,
	ProposeTaxType:           installTaxType,
	ProposeNewVariable:       installNewVariable,
	ProposeCreateAccount:     installNewAccount,
	ProposeAccountPermission: installAccountPermission,
	ProposeNewRole:           installNewRole,
	ProposeAddPermission:     installAddPermission,
}

Installation procedures

View Source
var VerifyPredicate = map[string]func(predicate *Rule, cratos *Cratos) bool{
	ProposeTax:               func(p *Rule, cratos *Cratos) bool { return true },
	ProposeTaxVar:            func(p *Rule, cratos *Cratos) bool { return true },
	ProposeTaxRevenueTarget:  func(p *Rule, cratos *Cratos) bool { return true },
	ProposeTaxType:           checkTaxType,
	ProposeNewVariable:       checkNewVar,
	ProposeCreateAccount:     func(p *Rule, cratos *Cratos) bool { return true },
	ProposeAccountPermission: func(p *Rule, cratos *Cratos) bool { return true },
	ProposeNewRole:           func(p *Rule, cratos *Cratos) bool { return true },
	ProposeAddPermission:     func(p *Rule, cratos *Cratos) bool { return true },
}

Basic predicate integrity check

Functions

This section is empty.

Types

type Amendment

type Amendment struct {
	Name       string
	Predicates []Rule
	SignedStampedDoc
}

func (Amendment) PartToSign

func (a Amendment) PartToSign() []byte

type ApprovedClaim

type ApprovedClaim struct {
	Claim Claim
	SignedStampedDoc
}

func (ApprovedClaim) PartToSign

func (approved ApprovedClaim) PartToSign() []byte

type Ballots

type Ballots struct {
	Vote []OpenBallot
}

type Block

type Block struct {
	// header
	Index    uint32
	Previous CidLink `json:",omitempty"`
	Network  string

	// data
	Demos     CidLink
	Cratos    CidLink
	Currency  CidLink
	Notary    CidLink `json:",omitempty"`
	Evidences []Evidence

	// validation
	SignedStampedDoc
	Difficulty CidLink
	Nonce      string
	PoWHash    string
}

the hash is not part of the block itself as it is the ipfs cid

func (*Block) HashPow

func (block *Block) HashPow()

func (Block) IsHashValid

func (block Block) IsHashValid(difficulty PersonalizedAdaptivePoW) bool

func (Block) PartToHash

func (block Block) PartToHash() string

func (Block) PartToSign

func (block Block) PartToSign() []byte

func (Block) Redacted

func (block Block) Redacted() interface{}

type CategoryVariable

type CategoryVariable string

func ParseCategoryVar

func ParseCategoryVar(s string) CategoryVariable

func (CategoryVariable) Description

func (v CategoryVariable) Description() string

func (CategoryVariable) FloatValue

func (v CategoryVariable) FloatValue() float64

func (CategoryVariable) IsLegal

func (v CategoryVariable) IsLegal(s string) bool
type CidLink struct {
	Link string `json:"/,omitempty"`
}

==== Other stuff ====

type CitizenOfName

type CitizenOfName struct {
	PublicKey        []string
	CitizenshipClaim CidLink
}

type Claim

type Claim struct {
	ChosenName string
	Role       string
	SignedStampedDoc
}

func (Claim) Expired

func (c Claim) Expired() bool

func (Claim) PartToSign

func (c Claim) PartToSign() []byte

type Claims

type Claims struct {
	Claim []ApprovedClaim
}

type Cratos

type Cratos struct {
	Roles Roles
	//Votes              map[string]OpenBallot
	Claims           Claims
	Variables        map[string]Vars
	ProposePredicate []string
	//VarVotesByNameByPk map[string]map[string]interface{}
	Taxes          map[string]Tax
	PublicAccounts map[string]PublicAccount
}

type Currency

type Currency struct {
	Name         string
	MonetaryMass uint64
	UnitBase     uint8
	//Inflation     float32
	CitizenCount  uint32
	Dividend      uint64
	Wallets       map[string]uint64
	JointWallets  map[string]uint64
	PublicWallets map[string]uint64
}

func (Currency) SumAccounts

func (ccy Currency) SumAccounts() uint64

type Demos

type Demos struct {
	Population       uint64
	CitizensByName   map[string]CitizenOfName
	PublicKeysByRole map[string][]string
}

type Evidence

type Evidence struct {
	CidLink
	Object interface{}
}

type Expirable

type Expirable interface {
	Expired() bool
}

type IntegerVariable

type IntegerVariable int64

func ParseIntegerVar

func ParseIntegerVar(s string) IntegerVariable

func (IntegerVariable) Description

func (v IntegerVariable) Description() string

func (IntegerVariable) FloatValue

func (v IntegerVariable) FloatValue() float64

func (IntegerVariable) IsLegal

func (v IntegerVariable) IsLegal(s string) bool

type IssuedBlock

type IssuedBlock struct {
	Issuer      string
	Time        int64
	IssuerCount int
	Frame       int
	FrameVar    int
}

type JointWallet

type JointWallet struct {
	PublicKeys []string
	Balance    uint64
}

type MultiPartyDocument

type MultiPartyDocument struct {
	Timestamp int64
	// contains filtered or unexported fields
}

Associate Public Keys to a crypted Pointer and a signature

type Notary

type Notary struct {
	Documents []MultiPartyDocument
}

func (*Notary) AddDoc

func (n *Notary) AddDoc(time int64, users []string, signatures []string, links []CidLink)

type Observable

type Observable interface {
	Register(observer Observer)
	Deregister(observer Observer)
	NotifyAll()
}

Observer pattern

type ObservableList

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

func (*ObservableList) Deregister

func (c *ObservableList) Deregister(o Observer)

func (*ObservableList) NotifyAll

func (c *ObservableList) NotifyAll()

func (*ObservableList) Register

func (c *ObservableList) Register(o Observer)

type Observer

type Observer interface {
	Update(string)
	GetID() string
}

type OpenBallot

type OpenBallot struct {
	Permission string
	VoteObject string
	VoteValue  string
	SignedStampedDoc
}

func (OpenBallot) PartToSign

func (b OpenBallot) PartToSign() []byte

type PersonalizedAdaptivePoW

type PersonalizedAdaptivePoW struct {
	AvgGenTime         float64 // # of seconds between each blocks
	CommonDifficulty   uint
	PreviousBlockTimes []int64
	PersonalHandicap   map[string]uint
	IssuersFrame       []IssuedBlock
}

func (PersonalizedAdaptivePoW) DifficultyFor

func (pow PersonalizedAdaptivePoW) DifficultyFor(user string) (uint, float64)

func (PersonalizedAdaptivePoW) GetGlobalDifficulty

func (pow PersonalizedAdaptivePoW) GetGlobalDifficulty(oldBlock Block) (globalDiff uint, prevTime []int64, issuerFrame []IssuedBlock)

func (PersonalizedAdaptivePoW) GetIssuerFrame

func (pow PersonalizedAdaptivePoW) GetIssuerFrame(block Block, issuerCount int) int

func (PersonalizedAdaptivePoW) GetMedianAndCount

func (pow PersonalizedAdaptivePoW) GetMedianAndCount(user string) (medianOfBlocksCount float64, nbPersonalBlocksInFrame float64, nbBlockSinceLast float64, issuersCount float64, previousIssuersCount float64)

func (PersonalizedAdaptivePoW) GetNbZerosAndRemainder

func (pow PersonalizedAdaptivePoW) GetNbZerosAndRemainder() (int, int)

func (PersonalizedAdaptivePoW) MaxGenTime

func (pow PersonalizedAdaptivePoW) MaxGenTime() float64

func (PersonalizedAdaptivePoW) MaxSpeed

func (pow PersonalizedAdaptivePoW) MaxSpeed() float64

func (PersonalizedAdaptivePoW) MinGenTime

func (pow PersonalizedAdaptivePoW) MinGenTime() float64

func (PersonalizedAdaptivePoW) MinSpeed

func (pow PersonalizedAdaptivePoW) MinSpeed() float64

func (PersonalizedAdaptivePoW) PartToSign

func (pow PersonalizedAdaptivePoW) PartToSign() []byte

type PubkeysOfRole

type PubkeysOfRole struct {
}

type PublicAccount

type PublicAccount struct {
	Name       string
	Permission string
}

type PublicWallet

type PublicWallet struct {
	Name    string
	Balance uint64
}

type Roles

type Roles struct {
	Permission  map[string][]string
	Inheritance map[string][]string
}

type Rule

type Rule struct {
	Subject   string
	Predicate string
	Object    string
}

type Signable

type Signable interface {
	PartToSign() []byte
	Details() (pk string, sign []byte)
	GetSignature() string
	GetPublicKey() string
	Stamp(SignedStampedDoc)
}

type SignedStampedDoc

type SignedStampedDoc struct {
	Timestamp int64
	PublicKey string
	Signature string
}

==== Signature related stuff ====

func (SignedStampedDoc) Details

func (d SignedStampedDoc) Details() (pk string, sign []byte)

func (SignedStampedDoc) GetPublicKey

func (d SignedStampedDoc) GetPublicKey() string

func (SignedStampedDoc) GetSignature

func (d SignedStampedDoc) GetSignature() string

func (SignedStampedDoc) PartToSign

func (d SignedStampedDoc) PartToSign() []byte

func (*SignedStampedDoc) Stamp

func (d *SignedStampedDoc) Stamp(s SignedStampedDoc)

type Tax

type Tax struct {
	Name     string
	Variable string
	Account  string
	Type     uint8
}

type Transaction

type Transaction struct {
	SignedStampedDoc
	To     string
	Amount uint64
}

func (Transaction) PartToSign

func (t Transaction) PartToSign() []byte

type UnitIntervalVariable

type UnitIntervalVariable float64

func ParseUnitIntervalVar

func ParseUnitIntervalVar(s string) UnitIntervalVariable

func (UnitIntervalVariable) Description

func (v UnitIntervalVariable) Description() string

func (UnitIntervalVariable) FloatValue

func (v UnitIntervalVariable) FloatValue() float64

func (UnitIntervalVariable) IsLegal

func (v UnitIntervalVariable) IsLegal(s string) bool

type Value

type Value interface{}

type Vars

type Vars struct {
	//Name string
	Type      string
	Value     interface{}
	VotesByPk map[string]interface{}
}

func (*Vars) Avg

func (variable *Vars) Avg() interface{}

type VoteableVariable

type VoteableVariable interface {
	IsLegal(s string) bool
	//Parse(s string, res interface{})
	Description() string
	FloatValue() float64
}

type Wallet

type Wallet struct {
	PublicKey string
	Balance   uint64
}

type Wrapper

type Wrapper struct {
	CID  string
	Type string
	Data interface{}
}

Jump to

Keyboard shortcuts

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