Documentation ¶
Index ¶
- Variables
- func VerifyTransferHash(sign Sign, transferHash Hash, publicKey *btcec.PublicKey) error
- type AccID
- type BigChain
- type Chain
- type Hash
- func GetHash(h hash.Hash, txn *Txn) Hash
- func GetHashDefault(txn *Txn) Hash
- func GetHashFromString(s string) (Hash, error)
- func GetSettingsHash(h hash.Hash, s *Settings) Hash
- func GetSettingsHashDefault(s *Settings) Hash
- func GetSettingsRequestHash(h hash.Hash, s *Settings) Hash
- func GetSettingsRequestHashDefault(s *Settings) Hash
- func GetTransferHash(h hash.Hash, t Transfer) Hash
- func GetTransferHashDefault(t Transfer) Hash
- func HashFromString(s string) Hash
- type ID
- type Preloader
- type PublicKey
- type Pusher
- type Router
- type Settings
- type SettingsChain
- type SettingsID
- type SettingsProcessor
- type SettingsPusher
- type SettingsResult
- type Sign
- type Transfer
- type TransferItem
- type TransferProcessor
- type TransferResult
- type Txn
- type TxnID
Constants ¶
This section is empty.
Variables ¶
var ( HashNew = sha256.New SigningCurve = btcec.S256() )
var ( ZeroHash Hash ZeroSign Sign )
Hash "nil" values for compare operations
var ( ErrInvalidHash = errors.New("invalid hash string") ErrInvalidSign = errors.New("invalid sign string") )
Parse errors
Functions ¶
Types ¶
type BigChain ¶
type BigChain interface {
Fetch(ctx context.Context, accID AccID, limit int) ([]Txn, *Settings, error)
}
BigChain is an global reliable storage for transactions and settings. It's is the only point of truth. In case of possible inconsistency all local account data is erased and refetched from BigChain.
type Chain ¶
type Chain interface { ListUnspentTxns(accID AccID) []Txn PutTo(accID AccID, txns []Txn) GetLastHash(accID AccID) Hash GetBalance(accID AccID) int64 GetLastTxn(accID AccID) *Txn GetLastNTxns(accID AccID, n int) []Txn Reset(AccID) }
Chain is an local cache of last account transaftions. It's used to process new transfers fast.
type Hash ¶
type Hash [32]byte
func GetHashDefault ¶
func GetHashFromString ¶
func GetSettingsHashDefault ¶
func GetTransferHashDefault ¶
func HashFromString ¶
type ID ¶
type ID uint64
ID is an transaction or settings id. It goes from 1 and up for each account, separate for transactions and settings.
type Preloader ¶
Preloader loads the most recent account data from reliable storage. It dosn't fetch data if it was fetched before and wasn't Reset
type Pusher ¶
Pusher is an general transfer pusher mechanism. It's used to push data to global storage, receiver's node, third parties and so on.
type Router ¶
type Router interface { // Returns host which is responsible for given key. // Key usually is an AccountID GetHostByKey(key string) string // All nodes hostnames of the cluster Nodes() []string // Sets cluster nodes SetNodes(nodes []string) // Checks if given node is our own, so we must process request not redirect it IsSelf(node string) bool }
Router is an cluster router. It's used to find node which is responsible for processing transactions of given account.
type Settings ¶
type Settings struct { ID ID Account AccID PublicKey PublicKey PrevHash, Hash Hash VerifyTransferSign bool DataHash Hash Sign Sign }
Settings is an account settings. Settings are form the similar chain as Txns are.
type SettingsChain ¶
type SettingsID ¶
SettingsID is an unique ID for each settings among all accounts.
func NewSettingsID ¶
func NewSettingsID(acc AccID, id ID) SettingsID
func (SettingsID) String ¶
func (t SettingsID) String() string
type SettingsProcessor ¶
type SettingsPusher ¶
Settings pusher is the same thing as Pusher but for Settings.
type SettingsResult ¶
type SettingsResult struct { SettingsID SettingsID // Last Settings ID Hash Hash // Hash Settings Hash }
SettingsResult is an result of settings change.
type Sign ¶
type Sign [72]byte
func GetSignFromString ¶
func SignFromString ¶
func SignTransfer ¶
func SignTransfer(transferHash Hash, privKey *btcec.PrivateKey) (Sign, error)
type Transfer ¶
type Transfer struct { Sender AccID Batch []*TransferItem // Receivers and amounts Sign Sign // Request sign. It will be kept at first transaction of the batch PrevHash Hash // Hash of last output transaction for Sender account SettingsID ID // Current account settings ID for Sender account }
Transfer is an request to make transfer from an account to one or many others.
func NewSingleTransfer ¶
func (*Transfer) AddReceiver ¶
type TransferItem ¶
TransferItem is an part of Transfer request.
type TransferProcessor ¶
type TransferResult ¶
type TransferResult struct { TxnID TxnID // TxnID of the first transaction in the batch Hash Hash // Hash of last transaction in the batch SettingsId ID // Current settings ID }
TransferResult is an result of transfer.
type Txn ¶
type Txn struct { // Account incremental id for output transactions. ID ID Sender, Receiver AccID Amount int64 // Balance of the Sender account at the time just after this transaction has been processed. Balance int64 // Account settings id at the moment of this transaction processing. SettingsID ID // Stores ID of Receiver output transaction when this transaction was taken into account. // Set by Receiver. 0 if not spent yet. // It's not used for transaction Hash calculation. SpentBy ID // Previous transaction hash of the same Sender. PrevHash Hash // Hash is an hash of corrent transaction. Hash Hash // Transfer Sign. // If more that one transactions were in the batch only first contains sign of the whole request Sign Sign }
Txn is a single transaction between two accounts. It's a central structure of the project.
See chain package docs for information about how transactions are structured.