types

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: LGPL-3.0 Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrChainAlreadyExists - error definition describing a given chain that has already been registered in the coordinationChain
	ErrChainAlreadyExists = errors.New("chain already exists for given account")

	// ErrGenesisAlreadyExists - error definition describing a given chain with an existing genesis block
	ErrGenesisAlreadyExists = errors.New("chain already has existing genesis")

	// ErrIrrelevantTransaction - error definition describing a transaction outside the scope of the given chain
	ErrIrrelevantTransaction = errors.New("irrelevant transaction")

	// ErrInsufficientBalance - error definition describing a transaction worth more than the sender's balance
	ErrInsufficientBalance = errors.New("insufficient transaction sender balance")

	// ErrNilTransaction - error definition describing a query for a non-existent transaction
	ErrNilTransaction = errors.New("couldn't find transaction with given hash")

	// ErrDuplicateTransaction - error definition describing a transaction that already exists in a given chain
	ErrDuplicateTransaction = errors.New("duplicate transaction")

	// ErrInvalidPayload - error definition describing an invalid transaction payload
	ErrInvalidPayload = errors.New("invalid payload")
)
View Source
var (
	// ErrNilAddress - error definition describing an input of addresses of length 0
	ErrNilAddress = errors.New("nil address")

	// ErrNilNode - error definition describing a coordinationNode input of nil value
	ErrNilNode = errors.New("nil node")

	// ErrNilCoordinationChain - error definition describing a coordination chain that is nil in value
	ErrNilCoordinationChain = errors.New("nil coordination chain")

	// ErrClientOutOfDate - error definition describing a client that is out of date
	ErrClientOutOfDate = errors.New("client out of date (must upgrade client)")

	// ErrNoBootstrapNodes - error definition describing a network having no bootstrap nodes
	ErrNoBootstrapNodes = errors.New("== WARNING == no available bootstrap nodes")

	// ErrNilCoordinationChainCache - error definition describing a coordination chain that is nil in value, but must have its cache cleared
	ErrNilCoordinationChainCache = errors.New("nil coordination chain; nothing to clear")

	// ErrNilCoordinationChainPush - error definition describing a coordination chain that is nil in value, but must be pushed
	ErrNilCoordinationChainPush = errors.New("nil coordination chain; nothing to push")
)
View Source
var (
	// ErrAlreadySigned - error definition stating transaction has already been signed
	ErrAlreadySigned = errors.New("transaction already signed")

	// ErrNilSignature - error definition describing nil tx signature
	ErrNilSignature = errors.New("nil signature")

	// ErrInvalidSignature - error definition describing invalid tx signature (doesn't match public key)
	ErrInvalidSignature = errors.New("invalid signature")

	// ErrIsNotContractCall - error definition describing tx of non-contract-call type
	ErrIsNotContractCall = errors.New("transaction is not contract call")
)
View Source
var (
	// ErrInvalidPublicKey - error definition describing a public key input not equal to transaction sender address
	ErrInvalidPublicKey = errors.New("signing public key does not match transaction public key")

	// ErrCannotWitnessSelf - error definition describing a transaction that has already been signed by an attempted witness
	ErrCannotWitnessSelf = errors.New("cannot witness self-signed transaction")
)
View Source
var ErrBadChain = errors.New("chain out of date")

ErrBadChain - error describing input chain with tx length shorter than current

Functions

func GetAllLocalizedChains added in v0.5.1

func GetAllLocalizedChains() ([]string, error)

GetAllLocalizedChains gets a list of the locally-provided chains, and their addresses.

func HandleReceivedChain

func HandleReceivedChain(b []byte) error

HandleReceivedChain - handle received chain

func HandleReceivedContractCreation added in v0.5.1

func HandleReceivedContractCreation(b []byte) error

HandleReceivedContractCreation - handle received transaction creating contract

func HandleReceivedCoordinationChainRequest

func HandleReceivedCoordinationChainRequest() ([]byte, error)

HandleReceivedCoordinationChainRequest - handle received byte value for coordination chain request

func HandleReceivedCoordinationNode

func HandleReceivedCoordinationNode(b []byte, isArchival bool) error

HandleReceivedCoordinationNode - handle received node

func HandleReceivedStateRequest added in v0.5.1

func HandleReceivedStateRequest(b []byte) ([]byte, error)

HandleReceivedStateRequest - handle received contract state request

func HandleReceivedTransaction

func HandleReceivedTransaction(b []byte) error

HandleReceivedTransaction - handle received transaction

func JoinNetwork

func JoinNetwork(bootstrapNode string, archivalNode bool) error

JoinNetwork - join given network with bootstrap node address

func RegisterArchivalNode

func RegisterArchivalNode() error

RegisterArchivalNode - register archival node on network

func SignTransaction

func SignTransaction(transaction *Transaction, privateKey *ecdsa.PrivateKey) error

SignTransaction - sign given transaction

func StartManagedSync added in v0.5.0

func StartManagedSync(cacheClearOnly bool, archival bool, duration time.Duration)

StartManagedSync - start repeated intermittent sync

func StringLogs added in v0.5.1

func StringLogs(logs []*Log) string

StringLogs - get string representation of log slice

func SyncNetwork

func SyncNetwork(archival bool, updateRemote bool) error

SyncNetwork - download all chains

func VerifyTransactionSignature

func VerifyTransactionSignature(transaction *Transaction) (bool, error)

VerifyTransactionSignature - verify given transaction signature, returning false if signature invalid

Types

type Chain

type Chain struct {
	Account common.Address `json:"account"` // Chain account

	Transactions []*Transaction `json:"transactions"` // Transactions in chain

	Genesis common.Hash `json:"genesis"` // Genesis block hash

	ContractSource []byte `json:"contract"` // Contract

	NetworkID uint        `json:"network"` // Network ID (mainnet: 0, testnet: 1, etc...)
	ID        common.Hash `json:"ID"`      // Chain ID
}

Chain - account transactions chain

func FromBytes

func FromBytes(b []byte) (*Chain, error)

FromBytes - decode given byte array to chain

func HandleReceivedChainRequest

func HandleReceivedChainRequest(b []byte) (*Chain, error)

HandleReceivedChainRequest - handle chain request

func NewChain

func NewChain(account common.Address) (*Chain, error)

NewChain - initialize new chain

func NewContractChain added in v0.5.1

func NewContractChain(controlingAccount common.Address, contractSource []byte, deploymentTransaction *Transaction) (*Chain, error)

NewContractChain - initialize new contract chain

func ReadChainFromMemory

func ReadChainFromMemory(address common.Address) (*Chain, error)

ReadChainFromMemory - read chain from memory

func ReadGenesisChainFromMemory added in v0.5.1

func ReadGenesisChainFromMemory(config *config.ChainConfig) (*Chain, error)

ReadGenesisChainFromMemory reads a genesis chain based on a given chain config.

func (*Chain) AddTransaction

func (chain *Chain) AddTransaction(transaction *Transaction) error

AddTransaction - append given transaction to chain

func (*Chain) Bytes

func (chain *Chain) Bytes() []byte

Bytes - convert given chain to byte array

func (*Chain) CalculateBalance

func (chain *Chain) CalculateBalance() *big.Float

CalculateBalance - iterate through tx set, return balance

func (*Chain) CalculateTargetNonce added in v0.5.2

func (chain *Chain) CalculateTargetNonce() uint64

CalculateTargetNonce - calculate the next target nonce for the given chain.

func (*Chain) MakeEncodingSafe

func (chain *Chain) MakeEncodingSafe() error

MakeEncodingSafe - make all transactions in chain encoding safe

func (*Chain) MakeGenesis added in v0.5.1

func (chain *Chain) MakeGenesis(genesis *config.ChainConfig, genesisPrivateKey *ecdsa.PrivateKey) (common.Hash, error)

MakeGenesis - generate genesis blocks from genesis file

func (*Chain) QueryTransaction added in v0.3.0

func (chain *Chain) QueryTransaction(hash common.Hash) (*Transaction, error)

QueryTransaction - attempt to fetch transaction metadata in chain by hash

func (*Chain) QueryTransactionByParent added in v0.5.1

func (chain *Chain) QueryTransactionByParent(parentHash common.Hash) (*Transaction, error)

QueryTransactionByParent - attempt to fetch transaction with given parent

func (*Chain) RecoverSafeEncoding

func (chain *Chain) RecoverSafeEncoding() error

RecoverSafeEncoding - recover chain from safely encoded

func (*Chain) String

func (chain *Chain) String() string

String - convert given chain to string

func (*Chain) WriteToMemory

func (chain *Chain) WriteToMemory() error

WriteToMemory - write given chain to memory

type CoordinationChain

type CoordinationChain struct {
	Nodes []*CoordinationNode `json:"nodes"` // List of coordination nodes holding metadata regarding a specific address-space (e.g. 0x000-0x123)

	NetworkID uint        `json:"network"` // Network ID (e.g. mainnet: 0, testnet: 1, etc...)
	ChainID   common.Hash `json:"ID"`      // Chain ID
}

CoordinationChain - "master" chain holding metadata regarding all address-spaces

func CoordinationChainFromBytes

func CoordinationChainFromBytes(b []byte) (*CoordinationChain, error)

CoordinationChainFromBytes - decode coordination chain from given byte array

func NewCoordinationChain

func NewCoordinationChain() (*CoordinationChain, error)

NewCoordinationChain - initialize new CoordinationChain

func ReadCoordinationChainFromMemory

func ReadCoordinationChainFromMemory() (*CoordinationChain, error)

ReadCoordinationChainFromMemory - read coordinationChain from memory

func (*CoordinationChain) AddNode

func (coordinationChain *CoordinationChain) AddNode(coordinationNode *CoordinationNode, updateRemote bool) error

AddNode - append given coordination node to coordinationChain

func (*CoordinationChain) Bytes

func (coordinationChain *CoordinationChain) Bytes() []byte

Bytes - convert given coordinationChain to byte array

func (*CoordinationChain) ClearCache added in v0.5.0

func (coordinationChain *CoordinationChain) ClearCache() error

ClearCache - remove unresponsive nodes from given coordinationChain

func (*CoordinationChain) GetBalance

func (coordinationChain *CoordinationChain) GetBalance(address common.Address) (*big.Float, error)

GetBalance - attempt to get balance of account

func (*CoordinationChain) GetChain added in v0.5.1

func (coordinationChain *CoordinationChain) GetChain(address common.Address) (*Chain, error)

GetChain - attempt to fetch remote account/contract chain

func (*CoordinationChain) GetGenesis

func (coordinationChain *CoordinationChain) GetGenesis() (*CoordinationNode, error)

GetGenesis - iterate through coordination nodes, return genesis node

func (*CoordinationChain) PushNode

func (coordinationChain *CoordinationChain) PushNode(coordinationNode *CoordinationNode) error

PushNode - send new node to addresses in coordination chain

func (*CoordinationChain) QueryAddress

func (coordinationChain *CoordinationChain) QueryAddress(queryAddress common.Address) (*CoordinationNode, error)

QueryAddress - query for address in coordination chain

func (*CoordinationChain) QueryAllArchivalNodes

func (coordinationChain *CoordinationChain) QueryAllArchivalNodes() ([]string, error)

QueryAllArchivalNodes - get all archival nodes in coordination chain

func (*CoordinationChain) QueryArchivalNode

func (coordinationChain *CoordinationChain) QueryArchivalNode(address string) ([]*CoordinationNode, error)

QueryArchivalNode - query for archival node address in coordination chain

func (*CoordinationChain) QueryNode

func (coordinationChain *CoordinationChain) QueryNode(address string) (*CoordinationNode, error)

QueryNode - query for node address in coordination chain

func (*CoordinationChain) String

func (coordinationChain *CoordinationChain) String() string

String - convert given coordinationChain to string

func (*CoordinationChain) UpdateRemotes added in v0.5.0

func (coordinationChain *CoordinationChain) UpdateRemotes() error

UpdateRemotes - update remote coordinationChain instances

func (*CoordinationChain) WriteToMemory

func (coordinationChain *CoordinationChain) WriteToMemory() error

WriteToMemory - write given coordination chain to memory

type CoordinationNode

type CoordinationNode struct {
	Address   common.Address `json:"address"`   // Address
	Addresses []string       `json:"addresses"` // Node addresses in coordination node

	Origin time.Time `json:"origin"` // Time at initialization of coordination node

	Genesis bool `json:"genesis"` // Has genesis

	ID common.Hash `json:"id"` // Node ID
}

CoordinationNode - node holding metadata regarding a certain address-space

func CoordinationNodeFromBytes

func CoordinationNodeFromBytes(b []byte) (*CoordinationNode, error)

CoordinationNodeFromBytes - convert byte array to coordinationNode

func NewCoordinationNode

func NewCoordinationNode(address common.Address, foundingAddresses []string) (*CoordinationNode, error)

NewCoordinationNode - initialize new coordinationNode

func (*CoordinationNode) Bytes

func (coordinationNode *CoordinationNode) Bytes() []byte

Bytes - convert given coordinationNode to byte array

func (*CoordinationNode) String

func (coordinationNode *CoordinationNode) String() string

String - convert given coordinationNode to string

type Log added in v0.5.1

type Log struct {
	Type  LogKeyType `json:"type"`  // Log type
	Key   string     `json:"key"`   // Log key
	Value []byte     `json:"value"` // Log val
}

Log - log meta container

func NewLog added in v0.5.1

func NewLog(key string, value []byte, logType LogKeyType) *Log

NewLog - init log with given key value pair

func (*Log) String added in v0.5.1

func (log *Log) String() string

String - get string representation of log

type LogKeyType added in v0.5.1

type LogKeyType int

LogKeyType - log key type

const (
	// Return - return log key type
	Return LogKeyType = iota

	// Error - error log key type
	Error

	// Custom - custom log key type
	Custom
)

func (LogKeyType) String added in v0.5.1

func (l LogKeyType) String() string

String - get string representation of key type

type Signature

type Signature struct {
	PublicKey           *ecdsa.PublicKey `json:"-"` // Public key
	SerializedPublicKey []byte           // Serialized public key

	V []byte   // Hash signature value
	R *big.Int // Signature R
	S *big.Int // Signature S
}

Signature - struct containing signature values

func (*Signature) Bytes

func (signature *Signature) Bytes() []byte

Bytes - convert given signature to byte array

func (*Signature) String

func (signature *Signature) String() string

String - convert given signature to string

type StringTransaction added in v0.5.5

type StringTransaction struct {
	AccountNonce uint64 `json:"nonce"` // Nonce in set of account transactions

	HashNonce uint64 `json:"hash_nonce"` // Nonce to calculate valid hash

	SenderHex    string `json:"sender"`    // Transaction sender
	RecipientHex string `json:"recipient"` // Transaction recipient

	Amount float64 `json:"amount"` // Amount of coins sent in transaction

	Payload []byte `json:"payload"` // Misc. data transported with transaction

	Signature *Signature `json:"signature"` // Transaction signature meta

	ParentTx string `json:"parent_hash"` // Parent transaction

	Timestamp string `json:"time"` // Transaction timestamp

	DeployedContractAddress *common.Address `json:"contract"` // Contract instance

	ContractCreation bool `json:"is-init-contract"` // Should init contract
	Genesis          bool `json:"genesis"`          // Genesis

	State *vm.State `json:"state"` // State

	Logs []*Log `json:"logs"` // Logs

	HashHex string `json:"hash"` // Transaction hash
}

StringTransaction represents a human-readable transaction.

type Transaction

type Transaction struct {
	AccountNonce uint64 `json:"nonce"` // Nonce in set of account transactions

	HashNonce uint64 `json:"hash_nonce"` // Nonce to calculate valid hash

	Sender    *common.Address `json:"sender"`    // Transaction sender
	Recipient *common.Address `json:"recipient"` // Transaction recipient

	Amount *big.Float `json:"amount"` // Amount of coins sent in transaction

	Payload []byte `json:"payload"` // Misc. data transported with transaction

	Signature *Signature `json:"signature"` // Transaction signature meta

	ParentTx *common.Hash `json:"parent_hash"` // Parent transaction

	Timestamp time.Time `json:"time"` // Transaction timestamp

	DeployedContractAddress *common.Address `json:"contract"` // Contract instance

	ContractCreation bool `json:"is-init-contract"` // Should init contract
	Genesis          bool `json:"genesis"`          // Genesis

	State *vm.State `json:"state"` // State

	Logs []*Log `json:"logs"` // Logs

	Hash *common.Hash `json:"hash"` // Transaction hash
}

Transaction - primitive transaction type

func NewContractCreation added in v0.5.1

func NewContractCreation(nonce uint64, parentTx *Transaction, sender *common.Address, contractInstance *common.Address, amount *big.Float, payload []byte) (*Transaction, error)

NewContractCreation - initialize contract designated to an initialized contract, calling contract constructor/provided constructor

func NewTransaction

func NewTransaction(nonce uint64, parentTx *Transaction, sender *common.Address, destination *common.Address, amount *big.Float, payload []byte) (*Transaction, error)

NewTransaction - attempt to initialize transaction primitive

func ReadTransactionFromMemory

func ReadTransactionFromMemory(hash common.Hash) (*Transaction, error)

ReadTransactionFromMemory - read transaction from memory

func TransactionFromBytes

func TransactionFromBytes(b []byte) (*Transaction, error)

TransactionFromBytes - serialize transaction from byte array

func (*Transaction) Bytes

func (transaction *Transaction) Bytes() []byte

Bytes - convert given transaction to byte array

func (*Transaction) EvaluateNewState added in v0.6.0

func (transaction *Transaction) EvaluateNewState(gasPolicy *compiler.GasPolicy) (*vm.State, error)

EvaluateNewState evaluates the new state for a given transaction. Does not set the transactions' state, but does return pointer to new state.

func (*Transaction) MakeEncodingSafe

func (transaction *Transaction) MakeEncodingSafe() error

MakeEncodingSafe - encode transaction to safe format

func (*Transaction) Publish

func (transaction *Transaction) Publish() error

Publish - publish given transaction

func (*Transaction) RecoverSafeEncoding

func (transaction *Transaction) RecoverSafeEncoding() error

RecoverSafeEncoding - recover transaction from safe encoding

func (*Transaction) String

func (transaction *Transaction) String() string

String - convert given transaction to string

func (*Transaction) WriteToMemory

func (transaction *Transaction) WriteToMemory() error

WriteToMemory - write given transaction to memory

type TransactionMetaResolver added in v0.6.1

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

TransactionMetaResolver outlines the default go-summercash WASM tx meta resolver.

func (*TransactionMetaResolver) ResolveFunc added in v0.6.1

func (r *TransactionMetaResolver) ResolveFunc(module, field string) vm.FunctionImport

ResolveFunc defines a set of import functions that may be called within a WebAssembly module.

func (*TransactionMetaResolver) ResolveGlobal added in v0.6.1

func (r *TransactionMetaResolver) ResolveGlobal(module, field string) int64

ResolveGlobal defines a set of global variables for use within a WebAssembly module.

type Witness

type Witness struct {
	Signature *Signature // Witness signature

	Address common.Address // Witnessing address

	Weight float64 // Witness weight (stake)
}

Witness - struct containing transaction witness values

func (*Witness) Bytes

func (witness *Witness) Bytes() []byte

Bytes - convert given witness to byte array

func (*Witness) String

func (witness *Witness) String() string

String - convert given witness to string

Jump to

Keyboard shortcuts

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