Documentation ¶
Index ¶
- Constants
- Variables
- func Compare(l, r CD) int
- func UtxoLength() uint64
- type CD
- type ConcurrentFinalized
- type ConcurrentTxnLog
- type IncrLedger
- func (ledger *IncrLedger) AllInputsExist(txn Transaction) bool
- func (ledger *IncrLedger) Balance(walletAddr crypto.WalletAddress) uint64
- func (ledger *IncrLedger) CheckNumber(walletAddr crypto.WalletAddress) uint16
- func (ledger *IncrLedger) Child() Ledger
- func (ledger *IncrLedger) Compact(compacted Ledger)
- func (ledger *IncrLedger) ExpectedCheckNumber(walletAddr crypto.WalletAddress) uint16
- func (ledger *IncrLedger) HeaderLength() uint64
- func (ledger *IncrLedger) IsValid(txn Transaction) error
- func (ledger *IncrLedger) Length() uint64
- func (ledger *IncrLedger) MarshalBinary() ([]byte, error)
- func (ledger *IncrLedger) Parent() Ledger
- func (ledger *IncrLedger) ProcessQueued() error
- func (ledger *IncrLedger) QueueFinalized(txns ...Transaction)
- func (ledger *IncrLedger) SetChild(child Ledger)
- func (ledger *IncrLedger) SetParent(parent Ledger)
- func (ledger *IncrLedger) TxnLog() []ids.TransactionId
- func (ledger *IncrLedger) TxnLogLength() uint64
- func (ledger *IncrLedger) UnmarshalBinary(data []byte) error
- func (ledger *IncrLedger) UpdateTxnLog(txns ...Transaction)
- func (ledger *IncrLedger) Utxos(walletAddr crypto.WalletAddress) []Utxo
- func (ledger *IncrLedger) Wait()
- func (ledger *IncrLedger) WalletMapsLength() uint64
- func (ledger *IncrLedger) WalletState(wal crypto.WalletAddress) (*walletState, bool)
- type Ledger
- type LedgerType
- type Mint
- func (mint Mint) CheckNumber() uint16
- func (mint *Mint) ConflictDomain() CD
- func (mint Mint) Data() []byte
- func (mint *Mint) HasValidOutput() bool
- func (mint *Mint) Hash() TransactionHash
- func (mint *Mint) Inputs() []Utxo
- func (mint *Mint) IsSlashable() bool
- func (mint Mint) IsValid() bool
- func (mint Mint) Length() uint16
- func (mint Mint) MarshalBinary() ([]byte, error)
- func (mint Mint) MarshalSignedBinary(wallet crypto.Wallet) ([]byte, error)
- func (mint Mint) Output(n int) (TransactionOutput, error)
- func (mint *Mint) SetId(tid ids.TransactionId)
- func (mint Mint) Source() crypto.WalletAddress
- func (mint *Mint) TxnId() ids.TransactionId
- func (mint Mint) Type() uint16
- func (mint *Mint) UnmarshalBinary(data []byte) error
- func (mint *Mint) UnmarshalSignedBinary(wallet crypto.Wallet, data []byte) error
- func (mint Mint) Value() Mint
- type MintCD
- type MintOutput
- type Payment
- func (pmt Payment) CheckNumber() uint16
- func (pmt *Payment) ConflictDomain() CD
- func (pmt Payment) Data() []byte
- func (pmt *Payment) HasValidOutput() bool
- func (pmt *Payment) Hash() TransactionHash
- func (pmt *Payment) Inputs() []Utxo
- func (pmt *Payment) IsSlashable() bool
- func (pmt Payment) IsValid() bool
- func (pmt Payment) Length() uint16
- func (pmt Payment) MarshalBinary() ([]byte, error)
- func (pmt Payment) MarshalSignedBinary(wallet crypto.Wallet) ([]byte, error)
- func (pmt Payment) Output(n int) (TransactionOutput, error)
- func (pmt *Payment) SetId(tid ids.TransactionId)
- func (pmt Payment) Source() crypto.WalletAddress
- func (pmt *Payment) TxnId() ids.TransactionId
- func (pmt Payment) Type() uint16
- func (pmt *Payment) UnmarshalBinary(data []byte) error
- func (pmt *Payment) UnmarshalSignedBinary(wallet crypto.Wallet, data []byte) error
- func (pmt Payment) Value() Payment
- type PaymentCD
- type PaymentOutput
- type SSLedger
- func (l *SSLedger) Balance(w crypto.WalletAddress) uint64
- func (l *SSLedger) CheckNumber(w crypto.WalletAddress) uint16
- func (l *SSLedger) Child() Ledger
- func (ssl *SSLedger) Compact(l Ledger)
- func (l *SSLedger) ExpectedCheckNumber(w crypto.WalletAddress) uint16
- func (ledger *SSLedger) HeaderLength() uint64
- func (ledger *SSLedger) IsValid(txn Transaction) error
- func (ledger *SSLedger) Length() uint64
- func (ledger *SSLedger) MarshalBinary() ([]byte, error)
- func (l *SSLedger) Parent() Ledger
- func (ledger *SSLedger) ProcessQueued() error
- func (ledger *SSLedger) QueueFinalized(_ ...Transaction)
- func (l *SSLedger) SetChild(child Ledger)
- func (l *SSLedger) SetParent(_ Ledger)
- func (l *SSLedger) TxnLog() []ids.TransactionId
- func (ledger *SSLedger) TxnLogLength() uint64
- func (ledger *SSLedger) UnmarshalBinary(data []byte) error
- func (l *SSLedger) Utxos(w crypto.WalletAddress) []Utxo
- func (ledger *SSLedger) Wait()
- func (ledger *SSLedger) WalletMapsLength() uint64
- func (l *SSLedger) WalletState(w crypto.WalletAddress) (*walletState, bool)
- type Sweep
- func (sweep Sweep) CheckNumber() uint16
- func (sweep *Sweep) ConflictDomain() CD
- func (sweep Sweep) Data() []byte
- func (sweep *Sweep) HasValidOutput() bool
- func (sweep *Sweep) Hash() TransactionHash
- func (sweep *Sweep) Inputs() []Utxo
- func (sweep *Sweep) IsSlashable() bool
- func (sweep Sweep) IsValid() bool
- func (sweep Sweep) Length() uint16
- func (sweep Sweep) MarshalBinary() ([]byte, error)
- func (sweep Sweep) MarshalSignedBinary(wallet crypto.Wallet) ([]byte, error)
- func (sweep Sweep) Output(n int) (TransactionOutput, error)
- func (sweep *Sweep) SetId(tid ids.TransactionId)
- func (sweep Sweep) Source() crypto.WalletAddress
- func (sweep *Sweep) TxnId() ids.TransactionId
- func (sweep Sweep) Type() uint16
- func (sweep *Sweep) UnmarshalBinary(data []byte) error
- func (sweep *Sweep) UnmarshalSignedBinary(wallet crypto.Wallet, data []byte) error
- func (sweep Sweep) Value() Sweep
- type SweepCD
- type SweepOutput
- type T
- type Transaction
- type TransactionHash
- type TransactionOutput
- type Utxo
- type WalletStates
- type WalletStatesSequence
Constants ¶
const ( PaymentTxn uint16 = 0 MintTxn uint16 = 1 SweepTxn uint16 = 2 TestingTxn uint16 = 3 )
Variables ¶
var ( NumWalletsInLedger = prometheus.NewGauge(prometheus.GaugeOpts{ Name: "num_wallets_in_ledger", Help: "Number of wallets in the Ledger.", }) NumUtxosInWallets = prometheus.NewGauge(prometheus.GaugeOpts{ Name: "num_utxos_in_wallets", Help: "Net number of UTXOs in all wallets.", }) TxnsOutputsTotalFinalized = prometheus.NewCounter(prometheus.CounterOpts{ Name: "casanova_txns_outputs_finalized_total", Help: "Total output transactions finalized.", }) )
Functions ¶
func UtxoLength ¶
func UtxoLength() uint64
Types ¶
type CD ¶
type CD interface { Source() crypto.WalletAddress CheckNumber() uint16 Uint64() uint64 Length() uint16 MarshalBinary() ([]byte, error) // contains filtered or unexported methods }
func UnmarshalCD ¶
NB(chuck): Kinda dumb, but we can't have an UnmarshalBinary([]byte) error interface function for a CD. That would require changing the CD interface from being an interface to {MintCD, PaymentCD, SweepCD} to being an interface to {*MintCD, *PaymentCD, *SweepCD} (since UnmarshalBinary must have a pointer receiver). This changes all the Consensus stuff because we could no longer readily store/lookup CDs in maps or check them for equality, due to the fact that we'd be comparing pointers instead of structs.
type ConcurrentFinalized ¶
type ConcurrentFinalized struct {
// contains filtered or unexported fields
}
func (*ConcurrentFinalized) Add ¶
func (cfin *ConcurrentFinalized) Add(txn Transaction)
func (*ConcurrentFinalized) Length ¶
func (cfin *ConcurrentFinalized) Length() int
func (*ConcurrentFinalized) Range ¶
func (cfin *ConcurrentFinalized) Range(f func(tid ids.TransactionId, txn Transaction) bool)
type ConcurrentTxnLog ¶
type ConcurrentTxnLog struct {
// contains filtered or unexported fields
}
func (*ConcurrentTxnLog) Add ¶
func (ctl *ConcurrentTxnLog) Add(tids ...ids.TransactionId)
type IncrLedger ¶
type IncrLedger struct { TxnLog_ *ConcurrentTxnLog Finalized_ *ConcurrentFinalized Parent_ Ledger Child_ Ledger Wg sync.WaitGroup // contains filtered or unexported fields }
func NewIncrLedger ¶
func NewIncrLedger(parent Ledger) *IncrLedger
func (*IncrLedger) AllInputsExist ¶
func (ledger *IncrLedger) AllInputsExist(txn Transaction) bool
func (*IncrLedger) Balance ¶
func (ledger *IncrLedger) Balance(walletAddr crypto.WalletAddress) uint64
func (*IncrLedger) CheckNumber ¶
func (ledger *IncrLedger) CheckNumber(walletAddr crypto.WalletAddress) uint16
func (*IncrLedger) Child ¶
func (ledger *IncrLedger) Child() Ledger
func (*IncrLedger) Compact ¶
func (ledger *IncrLedger) Compact(compacted Ledger)
See the more comprehensive description of the Compact routine detailed for the SSLedger. In short, this function compacts the receiver, ledger, into the argument. The function is only defined for an argument of type SSLedger.
func (*IncrLedger) ExpectedCheckNumber ¶
func (ledger *IncrLedger) ExpectedCheckNumber(walletAddr crypto.WalletAddress) uint16
func (*IncrLedger) HeaderLength ¶
func (ledger *IncrLedger) HeaderLength() uint64
func (*IncrLedger) IsValid ¶
func (ledger *IncrLedger) IsValid(txn Transaction) error
func (*IncrLedger) Length ¶
func (ledger *IncrLedger) Length() uint64
func (*IncrLedger) MarshalBinary ¶
func (ledger *IncrLedger) MarshalBinary() ([]byte, error)
func (*IncrLedger) Parent ¶
func (ledger *IncrLedger) Parent() Ledger
func (*IncrLedger) ProcessQueued ¶
func (ledger *IncrLedger) ProcessQueued() error
*IncrLedger.ProcessQueued attempts to process all transactions that failed to process initially with *IncrLedger.QueueFinalized. Some or all of the transactions in the list may just require that they be processed in a particular order (e.g. sequential checknumbers from the same wallet, or a transaction that spends a UTXO generated by another transaction in the list). It continues re-attempting processing of each transaction until no more can be processed. At that point it returns a composite error message for each of the failed transactions.
func (*IncrLedger) QueueFinalized ¶
func (ledger *IncrLedger) QueueFinalized(txns ...Transaction)
*IncrLedger.QueueFinalized checks if the transactions in the provided list are valid, and if so attempts to process them. If an error is encountered in either of these processes, the transaction is queued to be re-attempted, as it may just need another finalized transaction to process first.
func (*IncrLedger) SetChild ¶
func (ledger *IncrLedger) SetChild(child Ledger)
func (*IncrLedger) SetParent ¶
func (ledger *IncrLedger) SetParent(parent Ledger)
func (*IncrLedger) TxnLog ¶
func (ledger *IncrLedger) TxnLog() []ids.TransactionId
func (*IncrLedger) TxnLogLength ¶
func (ledger *IncrLedger) TxnLogLength() uint64
func (*IncrLedger) UnmarshalBinary ¶
func (ledger *IncrLedger) UnmarshalBinary(data []byte) error
func (*IncrLedger) UpdateTxnLog ¶
func (ledger *IncrLedger) UpdateTxnLog(txns ...Transaction)
func (*IncrLedger) Utxos ¶
func (ledger *IncrLedger) Utxos(walletAddr crypto.WalletAddress) []Utxo
func (*IncrLedger) Wait ¶
func (ledger *IncrLedger) Wait()
func (*IncrLedger) WalletMapsLength ¶
func (ledger *IncrLedger) WalletMapsLength() uint64
func (*IncrLedger) WalletState ¶
func (ledger *IncrLedger) WalletState(wal crypto.WalletAddress) (*walletState, bool)
NB(chuck): Use this function for reading only. If the returned *ledgerMap was found in THIS ledger, it COULD be written to - but for safety the writeableWalletState(..) function should be used instead if that's the intent.
type Ledger ¶
type Ledger interface { WalletState(crypto.WalletAddress) (*walletState, bool) Utxos(crypto.WalletAddress) []Utxo TxnLog() []ids.TransactionId Parent() Ledger Child() Ledger Balance(crypto.WalletAddress) uint64 CheckNumber(crypto.WalletAddress) uint16 ExpectedCheckNumber(crypto.WalletAddress) uint16 IsValid(Transaction) error QueueFinalized(...Transaction) ProcessQueued() error Wait() SetParent(Ledger) SetChild(Ledger) Compact(Ledger) Length() uint64 MarshalBinary() ([]byte, error) UnmarshalBinary([]byte) error }
func UnmarshalLedger ¶
type Mint ¶
type Mint struct { // TODO(leaf): Document the wire format. Src crypto.WalletAddress CheckNumber_ uint16 Output_ MintOutput Hash_ *TransactionHash Bytes []byte Sig crypto.Signature ConflictDomain_ *MintCD TxnId_ ids.TransactionId }
func (Mint) CheckNumber ¶
func (*Mint) ConflictDomain ¶
func (*Mint) HasValidOutput ¶
func (*Mint) Hash ¶
func (mint *Mint) Hash() TransactionHash
func (*Mint) IsSlashable ¶
A mint is slashable if it was never valid and never will be (unlike the check for if it's valid, which is a determination that might change with time)
func (Mint) MarshalBinary ¶
func (Mint) MarshalSignedBinary ¶
func (*Mint) SetId ¶
func (mint *Mint) SetId(tid ids.TransactionId)
func (Mint) Source ¶
func (mint Mint) Source() crypto.WalletAddress
func (*Mint) TxnId ¶
func (mint *Mint) TxnId() ids.TransactionId
func (*Mint) UnmarshalBinary ¶
func (*Mint) UnmarshalSignedBinary ¶
type MintCD ¶
func (MintCD) CheckNumber ¶
func (MintCD) MarshalBinary ¶
func (MintCD) Source ¶
func (mint MintCD) Source() crypto.WalletAddress
type MintOutput ¶
type MintOutput struct { Amount_ uint64 Dest_ crypto.WalletAddress }
func (MintOutput) Amount ¶
func (out MintOutput) Amount() uint64
func (MintOutput) Dest ¶
func (out MintOutput) Dest() crypto.WalletAddress
func (MintOutput) Length ¶
func (pout MintOutput) Length() uint16
type Payment ¶
type Payment struct { // NB(leaf): The wire format here is as follows: // Source: 32 bytes // CheckNumber: 2 bytes // NumOutputs: 2 bytes // Outputs: 40 bytes/ea Src crypto.WalletAddress CheckNumber_ uint16 Inputs_ []Utxo Outputs_ []PaymentOutput Hash_ *TransactionHash Bytes []byte Sig crypto.Signature ConflictDomain_ *PaymentCD TxnId_ ids.TransactionId }
func (Payment) CheckNumber ¶
func (*Payment) ConflictDomain ¶
func (*Payment) HasValidOutput ¶
func (*Payment) Hash ¶
func (pmt *Payment) Hash() TransactionHash
func (*Payment) IsSlashable ¶
A payment is slashable if it was never valid and never will be (unlike the check for if it's valid, which is a determination that might change with time)
func (Payment) MarshalBinary ¶
func (Payment) MarshalSignedBinary ¶
func (*Payment) SetId ¶
func (pmt *Payment) SetId(tid ids.TransactionId)
func (Payment) Source ¶
func (pmt Payment) Source() crypto.WalletAddress
func (*Payment) TxnId ¶
func (pmt *Payment) TxnId() ids.TransactionId
func (*Payment) UnmarshalBinary ¶
func (*Payment) UnmarshalSignedBinary ¶
type PaymentCD ¶
type PaymentCD struct { fmt.Stringer Source_ crypto.WalletAddress CheckNumber_ uint16 Numeric uint64 }
func (PaymentCD) CheckNumber ¶
func (PaymentCD) MarshalBinary ¶
func (PaymentCD) Source ¶
func (pmt PaymentCD) Source() crypto.WalletAddress
type PaymentOutput ¶
type PaymentOutput struct { Amount_ uint64 Dest_ crypto.WalletAddress }
func (PaymentOutput) Amount ¶
func (out PaymentOutput) Amount() uint64
func (PaymentOutput) Dest ¶
func (out PaymentOutput) Dest() crypto.WalletAddress
func (PaymentOutput) Length ¶
func (pout PaymentOutput) Length() uint16
type SSLedger ¶
type SSLedger struct { TxnLog_ []ids.TransactionId SpentUtxos_ []Utxo Child_ Ledger Height_ uint64 // contains filtered or unexported fields }
func NewSSLedger ¶
func (*SSLedger) CheckNumber ¶
func (l *SSLedger) CheckNumber(w crypto.WalletAddress) uint16
func (*SSLedger) Compact ¶
NB(chuck): There is some overloading of terminology here (hence the switch statement) that makes this confusing. There are two compaction "processes", one which is the full compaction (i.e., go back to the last SSLedger and compact all ledgers since then into one new SSLedger), and individual ledger compaction (i.e. compact this one ledger - whatever its type - into one SSLedger). The general usage of Compact:
- ssl.Compact(IncrLedger): Go back to the last SSLedger and compact forward into the provided empty ssl (full compaction).
- ssl.Compact(SSLedger): Copy ssl into SSLedger.
- incr.Compact(SSLedger): Copy incr into SSLedger.
- incr.Compact(IncrLedger): undefined
Thus, generally Compact works as source.Compact(target) with the exception of ssl.Compact(IncrLedger), which traverses back to the last SSLedger and runs individual ledger.Compact(ssl) on each ledger to merge them into ssl.
func (*SSLedger) ExpectedCheckNumber ¶
func (l *SSLedger) ExpectedCheckNumber(w crypto.WalletAddress) uint16
func (*SSLedger) HeaderLength ¶
func (*SSLedger) IsValid ¶
func (ledger *SSLedger) IsValid(txn Transaction) error
func (*SSLedger) MarshalBinary ¶
func (*SSLedger) ProcessQueued ¶
func (*SSLedger) QueueFinalized ¶
func (ledger *SSLedger) QueueFinalized(_ ...Transaction)
func (*SSLedger) TxnLog ¶
func (l *SSLedger) TxnLog() []ids.TransactionId
func (*SSLedger) TxnLogLength ¶
func (*SSLedger) UnmarshalBinary ¶
func (*SSLedger) WalletMapsLength ¶
func (*SSLedger) WalletState ¶
func (l *SSLedger) WalletState(w crypto.WalletAddress) (*walletState, bool)
type Sweep ¶
type Sweep struct { // NB(leaf): The wire format here is as follows: // Source: 32 bytes // CheckNumber: 2 bytes // NumInputs: 2 bytes // Inputs: 34 bytes/ea // Output: 40 bytes // Signature: 64 bytes Src crypto.WalletAddress CheckNumber_ uint16 Inputs_ []Utxo Output_ SweepOutput Hash_ *TransactionHash Bytes []byte Sig crypto.Signature ConflictDomain_ *SweepCD TxnId_ ids.TransactionId }
func (Sweep) CheckNumber ¶
func (*Sweep) ConflictDomain ¶
func (*Sweep) HasValidOutput ¶
func (*Sweep) Hash ¶
func (sweep *Sweep) Hash() TransactionHash
func (*Sweep) IsSlashable ¶
A sweep is slashable if it was never valid and never will be (unlike the check for if it's valid, which is a determination that might change with time)
func (Sweep) IsValid ¶
TODO(chuck): we probably want more robust checks to ensure that the sweep isn't zero-value. As-is this relies on there being no zero-valued UTXOs in the system to begin with.
func (Sweep) MarshalBinary ¶
func (Sweep) MarshalSignedBinary ¶
func (*Sweep) SetId ¶
func (sweep *Sweep) SetId(tid ids.TransactionId)
func (Sweep) Source ¶
func (sweep Sweep) Source() crypto.WalletAddress
func (*Sweep) TxnId ¶
func (sweep *Sweep) TxnId() ids.TransactionId
func (*Sweep) UnmarshalBinary ¶
func (*Sweep) UnmarshalSignedBinary ¶
type SweepCD ¶
type SweepCD struct { fmt.Stringer Source_ crypto.WalletAddress CheckNumber_ uint16 Numeric uint64 }
func (SweepCD) CheckNumber ¶
func (SweepCD) MarshalBinary ¶
func (SweepCD) Source ¶
func (s SweepCD) Source() crypto.WalletAddress
type SweepOutput ¶
type SweepOutput struct { Amount_ uint64 Dest_ crypto.WalletAddress }
func (SweepOutput) Amount ¶
func (out SweepOutput) Amount() uint64
func (SweepOutput) Dest ¶
func (out SweepOutput) Dest() crypto.WalletAddress
func (SweepOutput) Length ¶
func (pout SweepOutput) Length() uint16
type Transaction ¶
type Transaction interface { Type() uint16 Length() uint16 ConflictDomain() CD Data() []byte Source() crypto.WalletAddress Output(n int) (TransactionOutput, error) Hash() TransactionHash IsValid() bool IsSlashable() bool HasValidOutput() bool CheckNumber() uint16 Inputs() []Utxo TxnId() ids.TransactionId SetId(ids.TransactionId) MarshalBinary() ([]byte, error) MarshalSignedBinary(crypto.Wallet) ([]byte, error) UnmarshalBinary([]byte) error UnmarshalSignedBinary(crypto.Wallet, []byte) error }
func UnmarshalTxn ¶
func UnmarshalTxn(data []byte) (Transaction, error)
type TransactionHash ¶
func HashTransaction ¶
func HashTransaction(t Transaction) TransactionHash
func (TransactionHash) Equal ¶
func (l TransactionHash) Equal(r TransactionHash) bool
func (TransactionHash) Greater ¶
func (l TransactionHash) Greater(r TransactionHash) bool
func (TransactionHash) IsEmpty ¶
func (th TransactionHash) IsEmpty() bool
func (TransactionHash) Lesser ¶
func (l TransactionHash) Lesser(r TransactionHash) bool
func (TransactionHash) Short ¶
func (h TransactionHash) Short() []byte
type TransactionOutput ¶
type TransactionOutput interface { Amount() uint64 Dest() crypto.WalletAddress }
type WalletStates ¶
type WalletStates struct {
// contains filtered or unexported fields
}
func (*WalletStates) Add ¶
func (ws *WalletStates) Add(wal crypto.WalletAddress, state *walletState) *walletState
func (*WalletStates) Get ¶
func (ws *WalletStates) Get(wal crypto.WalletAddress) (*walletState, bool)
func (*WalletStates) Index ¶
func (ws *WalletStates) Index(wal crypto.WalletAddress) uint64
func (*WalletStates) Length ¶
func (ws *WalletStates) Length() int
type WalletStatesSequence ¶
type WalletStatesSequence struct {
// contains filtered or unexported fields
}
func (*WalletStatesSequence) Add ¶
func (wss *WalletStatesSequence) Add(wal crypto.WalletAddress, state *walletState) *walletState
func (*WalletStatesSequence) Get ¶
func (wss *WalletStatesSequence) Get(wal crypto.WalletAddress) (*walletState, bool)
func (*WalletStatesSequence) Length ¶
func (wss *WalletStatesSequence) Length() int