core

package
v0.0.0-...-103dbe2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CoinFlagDirty = 0
	CoinFlagFresh = 1
)
View Source
const (
	HDPurpose = "48"
	HDNetwork = "Wizechain"
)
View Source
const DOGE_TESTNET_API_KEY = "571b-3bd9-8808-a3bd"
View Source
const TEST_API_BALANCE_URL = "https://block.io/api/v2/get_address_balance/?api_key=" + DOGE_TESTNET_API_KEY + "&labels=testwize"
View Source
const TEST_API_EST_NETFEE = "https://block.io/api/v2/get_network_fee_estimate/?api_key=" + DOGE_TESTNET_API_KEY
View Source
const TICKER_URL = "https://api.coingecko.com/api/v3/simple/price?ids=dogecoin&vs_currencies=usd"

Variables

View Source
var (
	CoinsDefaultCoinbase = false
	CoinsDefaultOutput   = 0
	CoinsDefaultHeight   = uint32(0)
	CoinsDefaultVersion  = 0
)
View Source
var (
	AddrPrefixWallet  = [2]byte{0x77, 0x32}
	AddrPrefixTX      = [2]byte{0x74, 0x31}
	AddrPrefixBlock   = [2]byte{0x62, 0x31}
	AddrPrefixContent = [2]byte{0x63, 0x63}
)
View Source
var (
	BitcoinAlphabet  = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
	IPFSAlphabet     = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
	FlickrAlphabet   = NewAlphabet("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")
	RippleAlphabet   = NewAlphabet("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz")
	WizegeneAlphabet = NewAlphabet("wWzZiIbcdeghjklmnopqQrstuxy123456789ABCDEGHKLMOPRSTUVXYaFf")
)

Alphabet: copy from https://en.wikipedia.org/wiki/Base58

View Source
var CurrencySymbol4Byte = [4]byte{0x57, 0x49, 0x5a, 0x45}
View Source
var (
	ErrorInvalidBase58String = errors.New("invalid base58 string")
)

Errors

View Source
var HDRoleActive = `0x1`
View Source
var HDRoleMemo = `0x3`
View Source
var HDRoleOwner = `0x0`
View Source
var HDRoleValidator = `0x4`
View Source
var HashFunc func(string) uint32 = func(s string) uint32 {
	var val uint32 = 1
	for i := 0; i < len(s); i++ {
		val += (val * 37) + uint32(s[i])
	}
	return val
}
View Source
var LivePrefix4Byte = [4]byte{0x06, 0x41, 0x02, 0x01}
View Source
var LocalPrefix4Byte = [4]byte{0x06, 0x41, 0x02, 0x03}
View Source
var TestPrefix4Byte = [4]byte{0x06, 0x41, 0x02, 0x02}

Functions

func CreateChildKey

func CreateChildKey(masterKey *tools.Key, index uint32) (*tools.Key, error)

func CreateFungibleTransaction

func CreateFungibleTransaction(from string, to string, value float32) error

func CreateGenesisTransaction

func CreateGenesisTransaction()

func CreateHDHierarchy

func CreateHDHierarchy(purpose, network, index, role, keyIndex string) string

func CreateMasterKey

func CreateMasterKey(keySeed []byte) *tools.Key

func CreateNewBlock

func CreateNewBlock(chainId string, lastHash []byte, lastBlockId uint32, version uint32) []byte

func CreateSeedForKey

func CreateSeedForKey() ([]byte, error)

func Decode

func Decode(input string, alphabet *Alphabet) ([]byte, error)

Decode docode with custom alphabet

func Encode

func Encode(input []byte, alphabet *Alphabet) string

Encode encode with custom alphabet

func GetBalanceFromAddress

func GetBalanceFromAddress(from string) float32

func GetChildPubKey

func GetChildPubKey(childKey *tools.Key) *tools.Key

func ValidateTXBeforeCreate

func ValidateTXBeforeCreate(tx *Transaction) error

func WriteGenesisToFile

func WriteGenesisToFile(data *Genesis)

func WriteInBlockToFile

func WriteInBlockToFile(blockData []byte)

Types

type Account

type Account Address

type Address

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

func (*Address) SeedToMnemonic

func (am *Address) SeedToMnemonic() string

func (*Address) ToString

func (am *Address) ToString() string

type AddressManager

type AddressManager struct {
	IAddress
}

func (AddressManager) Create

func (am AddressManager) Create(network [4]byte, prefix [2]byte) *Address

func (*AddressManager) NewAddressRing

func (am *AddressManager) NewAddressRing(network [4]byte, prefix [2]byte) *Address

func (AddressManager) ToString

func (am AddressManager) ToString() string

func (AddressManager) Validate

func (am AddressManager) Validate() bool

type Alphabet

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

Alphabet The base58 alphabet object.

func NewAlphabet

func NewAlphabet(alphabet string) *Alphabet

NewAlphabet create a custom alphabet from 58-length string. Note: len(rune(alphabet)) must be 58.

func (Alphabet) String

func (alphabet Alphabet) String() string

Alphabet's string representation

type Ancestor

type Ancestor struct {
	// contains filtered or unexported fields
}
var A *Ancestor

type Block

type Block struct {
	Header       *BlockHeader
	BlockVersion uint32
	Tx           []Transaction
	Payload      []byte
	// are sidechain blocks
	RightBlocks []Block
	// are parent chain blocks may be null if not a sidechain
	LeftBlocks           []Block
	Created              int64
	ElapsedSinceCreation uint64
	// contains filtered or unexported fields
}

func CreateRawBlock

func CreateRawBlock(chainId string, lastHash []byte, lastBlockId uint32, version uint32) *Block

func (*Block) CreateBlankBlock

func (b *Block) CreateBlankBlock(
	chainId string, lastHash []byte, lastBlockId uint32, version uint32) *Block

type BlockHeader

type BlockHeader struct {
	Id         uint32
	ChainID    string
	Version    uint32
	Height     uint32
	Hash       string
	MerkleRoot []byte
	Dna        string
	PrevHash   []byte
	Timestamp  int64
}

type BlockQueue

type BlockQueue struct {
	list.List
}

func NewBlockQueue

func NewBlockQueue() *BlockQueue

func (*BlockQueue) Add

func (q *BlockQueue) Add(block *Block)

func (*BlockQueue) GetTip

func (q *BlockQueue) GetTip() interface{}

type BlocksParams

type BlocksParams struct {
	MaxBlockPerYear float32
	CoinsPerBlock   int32
	MaxCoinsPerYear float64

	MaxSecPerBlock int64
	// contains filtered or unexported fields
}

type Coin

type Coin struct {
	ICoins
}

type CoinCache

type CoinCache struct {
	Entries map[uint32]CoinCacheEntry
	// contains filtered or unexported fields
}

type CoinCacheEntry

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

type Coinbase

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

type CoinbaseManager

type CoinbaseManager struct {
	ICoinbase
	// contains filtered or unexported fields
}

func NewCoinbase

func NewCoinbase() *CoinbaseManager

func (*CoinbaseManager) CalcMaskSize

func (cb *CoinbaseManager) CalcMaskSize()

func (*CoinbaseManager) SetCacheBackend

func (cb *CoinbaseManager) SetCacheBackend()

type Config

type Config struct {
	RepoPath string
	Logger   logging.Backend
	DB       *storm.DB
	Mnemonic string
	Created  time.Time
	Proxy    proxy.Dialer
}

type CurrencyConfig

type CurrencyConfig struct {
	Name      string
	MaxSupply int `json:"max_supply"`
}

type DNAProcessor

type DNAProcessor struct {
	IDna
}

func NewProcessor

func NewProcessor() *DNAProcessor

type DNARaw

type DNARaw struct {
	D []byte
	// contains filtered or unexported fields
}

func GetDNA

func GetDNA(popSize uint) (dnaProof *DNARaw)

type DNATrainer

type DNATrainer interface {
	GetTrainingSet() map[int]string

	Train() string
	// contains filtered or unexported methods
}

type DOGEInfo

type DOGEInfo struct {
	Liquidity_balance string
	Usd_value         float32
}

func GetDogeBalance

func GetDogeBalance() *DOGEInfo

func (*DOGEInfo) Balance

func (d *DOGEInfo) Balance()

func (*DOGEInfo) Value

func (d *DOGEInfo) Value()

type DnaTrainingData

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

type DnaTrainingSet

type DnaTrainingSet []DnaTrainingData

type Filter

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

func New

func New() *Filter

new filter with default size (640000 booleans, in 20000 uint32)

func NewSize

func NewSize(size int) *Filter

func (*Filter) Add

func (f *Filter) Add(w string)

add word to filter

func (*Filter) Clear

func (f *Filter) Clear()

func (*Filter) Marked

func (f *Filter) Marked(w string) bool

if this function returns false, w is not present

type Genesis

type Genesis struct {
	GenesisTime      int64              `json:"genesis_time"`
	ChainID          string             `json:"chain_id"`
	Balances         map[string]float32 `json:"balances"`
	Currency         *CurrencyConfig    `json:"currency"`
	POS              *POSParams         `json:"pos_parameters"`
	BlockchainParams *BlocksParams      `json:"blocks_parameters"`
	// contains filtered or unexported fields
}

func CreateGenesisBlock

func CreateGenesisBlock() (*Genesis, error)

func LoadGenesisFromJSON

func LoadGenesisFromJSON() *Genesis

type IAddress

type IAddress interface {
	Create(network [4]byte, prefix [2]byte) *Address

	Validate() bool
	ToString() string
	// contains filtered or unexported methods
}

type IBlock

type IBlock interface {
	CreateBlankBlock(chainId string, lastHash []byte, lastBlockId uint32, version uint32) *Block
	// contains filtered or unexported methods
}

type ICoinbase

type ICoinbase interface {
	Cleanup()
	ClearUnspendable()
	CalcMaskSize()
	Serialize() []byte
	UnSerialize() *Coin

	GetAddress() string
	GetUTXO(txID string) []Coin
	HaveUTXO(txID string) bool
	GetCoinBlock() *Block

	SetCacheBackend()

	AddCoin(outPoint int, coin Coin, possibleOverwrite bool)
	// contains filtered or unexported methods
}

type ICoins

type ICoins interface {
}

type IDna

type IDna interface {
	// contains filtered or unexported methods
}

type IOrganism

type IOrganism interface {
	// contains filtered or unexported methods
}

type IState

type IState interface {
	GetDatabase() *storm.DB
}

type ITransaction

type ITransaction interface {
	// contains filtered or unexported methods
}

type IValidator

type IValidator interface {
}

type IWizechain

type IWizechain interface {
	GetGenesis()
	SetGenesis()
	CreateBlock()
	GetTip() *Block
	GetEnd() *Block
	GetNumBlocks() int

	GetBlockIndex(blockIndex uint32) Block
	GetBlockHeader(blockIndex uint32) Block
	GetChainHeight() uint32
	// contains filtered or unexported methods
}

type Inputs

type Inputs struct {
	From  string  `json:"from"`
	To    string  `json:"to"`
	Value float32 `json:"value"`
	Data  string  `json:"data"`
}

func (*Inputs) IsStakingReward

func (t *Inputs) IsStakingReward() bool

type Organism

type Organism struct {
	DNA     []byte
	Fitness float64
	ParentA []byte
	ParentB []byte
	IOrganism
}
var O Organism

type Outpoint

type Outpoint struct {
	Hash []byte
	// contains filtered or unexported fields
}

func NewOutpoint

func NewOutpoint(hashIn []byte, nIn uint32) *Outpoint

NewOutpoint ...

func (*Outpoint) Serialize

func (o *Outpoint) Serialize()

type Outputs

type Outputs struct {
	From  string
	To    string
	Value float32
}

type POSParams

type POSParams struct {
	MinValidators              int
	MaxValidators              int
	Quorum                     float32
	MaxValidatorPower          float64
	ChangeLeaderFreq           float64
	StartingRewardPerValidator float64
	StartingRewardAsCurrency   float64
	InflationaryRate           float64
	DeflationaryRate           float64
}

type State

type State struct {
	Pk             int `storm:"id,increment"`
	IsGenesisState bool
	Balances       map[string]float32

	IState
	// contains filtered or unexported fields
}

func (*State) AddToMempool

func (s *State) AddToMempool(key string, value interface{})

func (*State) AddTx

func (s *State) AddTx(tx Transaction) error

AddTx ...

func (*State) CreateCache

func (s *State) CreateCache()

func (*State) CreateGenesisState

func (s *State) CreateGenesisState(db *storm.DB)

func (*State) GetCacheSize

func (s *State) GetCacheSize() int

func (*State) GetDatabase

func (s *State) GetDatabase() *storm.DB

func (*State) Persist

func (s *State) Persist() error

Persist ...

type Trainer

type Trainer struct {
	DNATrainer
}

func NewTrainer

func NewTrainer() *Trainer

func (*Trainer) GetTrainingSet

func (t *Trainer) GetTrainingSet() map[int]string

func (*Trainer) Train

func (t *Trainer) Train() string

type Transaction

type Transaction struct {
	Pk int `storm:"id,increment"`
	ITransaction
	Inputs          []*Inputs
	Outputs         []*Outputs
	IsCoinbase      bool
	IsStakingReward bool
}

func GetGenesisTransaction

func GetGenesisTransaction(db *storm.DB) (bool, []Transaction)

func (*Transaction) GetDatabase

func (t *Transaction) GetDatabase() *storm.DB

type Validator

type Validator struct {
	Address    string
	Staked     []Coin
	Weight     float64
	StakedWith string
}

type Validators

type Validators []Validator

type WalletInterface

type WalletInterface interface {
}

type Wizechain

type Wizechain struct {
	ID           string
	Chaincode    string
	Version      string
	Blocks       []*Block
	BlockHeaders []*BlockHeader

	MasterFingerPrint string
	MasterDNA         string
	// contains filtered or unexported fields
}

func NewWizeChain

func NewWizeChain(chaincode, version string) *Wizechain

func (*Wizechain) CreateBlock

func (w *Wizechain) CreateBlock()

func (*Wizechain) GetEnd

func (w *Wizechain) GetEnd() *Block

func (*Wizechain) GetGenesis

func (w *Wizechain) GetGenesis()

func (*Wizechain) GetNumBlocks

func (w *Wizechain) GetNumBlocks() int

func (*Wizechain) GetPreviousBlock

func (w *Wizechain) GetPreviousBlock() *Block

func (*Wizechain) GetTip

func (w *Wizechain) GetTip() *Block

func (*Wizechain) SetGenesis

func (w *Wizechain) SetGenesis()

Directories

Path Synopsis
p2p

Jump to

Keyboard shortcuts

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