Documentation ¶
Index ¶
- Variables
- func HandleReceivedChain(b []byte) error
- func HandleReceivedCoordinationChainRequest() ([]byte, error)
- func HandleReceivedCoordinationNode(b []byte) error
- func HandleReceivedTransaction(b []byte) error
- func JoinNetwork(bootstrapNode string, archivalNode bool) error
- func RegisterArchivalNode() error
- func SignTransaction(transaction *Transaction, privateKey *ecdsa.PrivateKey) error
- func SyncNetwork(archival bool) error
- func VerifyTransactionSignature(transaction *Transaction) (bool, error)
- type Chain
- func (chain *Chain) AddTransaction(transaction *Transaction) error
- func (chain *Chain) Bytes() []byte
- func (chain *Chain) CalculateBalance() float64
- func (chain *Chain) MakeEncodingSafe() error
- func (chain *Chain) RecoverSafeEncoding() error
- func (chain *Chain) String() string
- func (chain *Chain) WriteToMemory() error
- type CoordinationChain
- func (coordinationChain *CoordinationChain) AddNode(coordinationNode *CoordinationNode, updateRemote bool) error
- func (coordinationChain *CoordinationChain) Bytes() []byte
- func (coordinationChain *CoordinationChain) GetBalance(address common.Address) (float64, error)
- func (coordinationChain *CoordinationChain) GetGenesis() (*CoordinationNode, error)
- func (coordinationChain *CoordinationChain) PushNode(coordinationNode *CoordinationNode) error
- func (coordinationChain *CoordinationChain) QueryAddress(queryAddress common.Address) (*CoordinationNode, error)
- func (coordinationChain *CoordinationChain) QueryAllArchivalNodes() ([]string, error)
- func (coordinationChain *CoordinationChain) QueryArchivalNode(address string) ([]*CoordinationNode, error)
- func (coordinationChain *CoordinationChain) QueryNode(address string) (*CoordinationNode, error)
- func (coordinationChain *CoordinationChain) String() string
- func (coordinationChain *CoordinationChain) WriteToMemory() error
- type CoordinationNode
- type Signature
- type Transaction
- func (transaction *Transaction) Bytes() []byte
- func (transaction *Transaction) MakeEncodingSafe() error
- func (transaction *Transaction) Publish() error
- func (transaction *Transaction) RecoverSafeEncoding() error
- func (transaction *Transaction) String() string
- func (transaction *Transaction) WriteToMemory() error
- type Witness
Constants ¶
This section is empty.
Variables ¶
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 less than the sender's balance ErrInsufficientBalance = errors.New("insufficient transaction sender balance") )
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)") )
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") )
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") )
var ( // ErrBadChain - error describing input chain with tx length shorter than current ErrBadChain = errors.New("chain out of date") )
Functions ¶
func HandleReceivedChain ¶
HandleReceivedChain - handle received chain
func HandleReceivedCoordinationChainRequest ¶
HandleReceivedCoordinationChainRequest - handle received byte value for coordination chain request
func HandleReceivedCoordinationNode ¶
HandleReceivedCoordinationNode - handle received node
func HandleReceivedTransaction ¶
HandleReceivedTransaction - handle received transaction
func JoinNetwork ¶
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 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 NetworkID uint `json:"network"` // Network ID (mainnet: 0, testnet: 1, etc...) ID common.Hash `json:"ID"` // Chain ID }
Chain - account transactions chain
func HandleReceivedChainRequest ¶
HandleReceivedChainRequest - handle chain request
func ReadChainFromMemory ¶
ReadChainFromMemory - read chain from memory
func (*Chain) AddTransaction ¶
func (chain *Chain) AddTransaction(transaction *Transaction) error
AddTransaction - append given transaction to chain
func (*Chain) CalculateBalance ¶
CalculateBalance - iterate through tx set, return balance
func (*Chain) MakeEncodingSafe ¶
MakeEncodingSafe - make all transactions in chain encoding safe
func (*Chain) RecoverSafeEncoding ¶
RecoverSafeEncoding - recover chain from safely encoded
func (*Chain) WriteToMemory ¶
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) GetBalance ¶
func (coordinationChain *CoordinationChain) GetBalance(address common.Address) (float64, error)
GetBalance - attempt to get balance of account
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) 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 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
type Transaction ¶
type Transaction struct { AccountNonce uint64 `json:"nonce"` // Nonce in set of account transactions Sender *common.Address `json:"sender"` // Transaction sender Recipient *common.Address `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 *Transaction `json:"-"` // Parent transaction Timestamp time.Time `json:"time"` // Transaction timestamp Genesis bool `json:"genesis"` // Genesis Hash *common.Hash `json:"hash"` // Transaction hash }
Transaction - primitive transaction type
func NewTransaction ¶
func NewTransaction(nonce uint64, parentTx *Transaction, sender *common.Address, destination *common.Address, amount float64, 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) 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