Documentation
¶
Index ¶
- Constants
- Variables
- func All(tx UnconfirmedTxn) bool
- func CheckDatabase(db *dbutil.DB, pubkey cipher.PubKey, quit chan struct{}) error
- func CreateBuckets(db *dbutil.DB) error
- func DefaultWalker(tx *dbutil.Tx, hps []coin.HashPair) (cipher.SHA256, bool)
- func DropletPrecisionCheck(amount uint64) error
- func GetDistributionAddresses() []string
- func GetLockedDistributionAddresses() []string
- func GetUnlockedDistributionAddresses() []string
- func IsValid(tx UnconfirmedTxn) bool
- func MaxDropletDivisor() uint64
- func NewErrTxnViolatesHardConstraint(err error) error
- func NewErrTxnViolatesSoftConstraint(err error) error
- func NewErrTxnViolatesUserConstraint(err error) error
- func OpenDB(dbFile string, readOnly bool) (*dbutil.DB, error)
- func ReadableOutputsToUxBalances(ros ReadableOutputs) ([]wallet.UxBalance, error)
- func RepairCorruptDB(db *dbutil.DB, pubkey cipher.PubKey, quit chan struct{}) (*dbutil.DB, error)
- func ToAddresses(addresses []cipher.Address) func(UnconfirmedTxn) bool
- func TransactionIsLocked(inUxs coin.UxArray) bool
- func TransactionToJSON(tx coin.Transaction) (string, error)
- func VerifyBlockTxnConstraints(txn coin.Transaction, head *coin.SignedBlock, uxIn coin.UxArray) error
- func VerifySingleTxnHardConstraints(txn coin.Transaction, head *coin.SignedBlock, uxIn coin.UxArray) error
- func VerifySingleTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.UxArray, maxSize int) error
- func VerifySingleTxnUserConstraints(txn coin.Transaction) error
- type Blockchain
- func (bc *Blockchain) ExecuteBlock(tx *dbutil.Tx, sb *coin.SignedBlock) error
- func (bc Blockchain) GetBlocks(tx *dbutil.Tx, start, end uint64) ([]coin.SignedBlock, error)
- func (bc *Blockchain) GetGenesisBlock(tx *dbutil.Tx) (*coin.SignedBlock, error)
- func (bc Blockchain) GetLastBlocks(tx *dbutil.Tx, num uint64) ([]coin.SignedBlock, error)
- func (bc *Blockchain) GetSignedBlockByHash(tx *dbutil.Tx, hash cipher.SHA256) (*coin.SignedBlock, error)
- func (bc *Blockchain) GetSignedBlockBySeq(tx *dbutil.Tx, seq uint64) (*coin.SignedBlock, error)
- func (bc Blockchain) Head(tx *dbutil.Tx) (*coin.SignedBlock, error)
- func (bc *Blockchain) HeadSeq(tx *dbutil.Tx) (uint64, bool, error)
- func (bc Blockchain) Len(tx *dbutil.Tx) (uint64, error)
- func (bc Blockchain) NewBlock(tx *dbutil.Tx, txns coin.Transactions, currentTime uint64) (*coin.Block, error)
- func (bc *Blockchain) Time(tx *dbutil.Tx) (uint64, error)
- func (bc Blockchain) TransactionFee(tx *dbutil.Tx, headTime uint64) coin.FeeCalculator
- func (bc *Blockchain) Unspent() blockdb.UnspentPooler
- func (bc Blockchain) VerifyBlockTxnConstraints(tx *dbutil.Tx, txn coin.Transaction) error
- func (bc *Blockchain) VerifySignature(block *coin.SignedBlock) error
- func (bc Blockchain) VerifySingleTxnHardConstraints(tx *dbutil.Tx, txn coin.Transaction) error
- func (bc Blockchain) VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin.Transaction, maxSize int) error
- func (bc *Blockchain) WalkChain(workers int, f func(*dbutil.Tx, *coin.SignedBlock) error, quit chan struct{}) error
- type BlockchainConfig
- type BlockchainMetadata
- type Blockchainer
- type BuildInfo
- type Config
- type ErrCorruptDB
- type ErrTxnViolatesHardConstraint
- type ErrTxnViolatesSoftConstraint
- type ErrTxnViolatesUserConstraint
- type Historyer
- type ReadableBlock
- type ReadableBlockBody
- type ReadableBlockHeader
- type ReadableBlocks
- type ReadableOutput
- type ReadableOutputSet
- type ReadableOutputs
- type ReadableTransaction
- type ReadableTransactionInput
- type ReadableTransactionOutput
- type ReadableUnconfirmedTxn
- type Richlist
- type RichlistBalance
- type Transaction
- type TransactionJSON
- type TransactionOutputJSON
- type TransactionStatus
- type TxFilter
- type TxnUnspents
- type UnconfirmedTxn
- type UnconfirmedTxnPool
- func (utp *UnconfirmedTxnPool) ForEach(tx *dbutil.Tx, f func(cipher.SHA256, UnconfirmedTxn) error) error
- func (utp *UnconfirmedTxnPool) Get(tx *dbutil.Tx, hash cipher.SHA256) (*UnconfirmedTxn, error)
- func (utp *UnconfirmedTxnPool) GetIncomingOutputs(tx *dbutil.Tx, bh coin.BlockHeader) (coin.UxArray, error)
- func (utp *UnconfirmedTxnPool) GetKnown(tx *dbutil.Tx, txns []cipher.SHA256) (coin.Transactions, error)
- func (utp *UnconfirmedTxnPool) GetTxHashes(tx *dbutil.Tx, filter func(UnconfirmedTxn) bool) ([]cipher.SHA256, error)
- func (utp *UnconfirmedTxnPool) GetTxns(tx *dbutil.Tx, filter func(UnconfirmedTxn) bool) ([]UnconfirmedTxn, error)
- func (utp *UnconfirmedTxnPool) GetUnknown(tx *dbutil.Tx, txns []cipher.SHA256) ([]cipher.SHA256, error)
- func (utp *UnconfirmedTxnPool) GetUnspentsOfAddr(tx *dbutil.Tx, addr cipher.Address) (coin.UxArray, error)
- func (utp *UnconfirmedTxnPool) InjectTransaction(tx *dbutil.Tx, bc Blockchainer, txn coin.Transaction, maxSize int) (bool, *ErrTxnViolatesSoftConstraint, error)
- func (utp *UnconfirmedTxnPool) Len(tx *dbutil.Tx) (uint64, error)
- func (utp *UnconfirmedTxnPool) RawTxns(tx *dbutil.Tx) (coin.Transactions, error)
- func (utp *UnconfirmedTxnPool) RecvOfAddresses(tx *dbutil.Tx, bh coin.BlockHeader, addrs []cipher.Address) (coin.AddressUxOuts, error)
- func (utp *UnconfirmedTxnPool) Refresh(tx *dbutil.Tx, bc Blockchainer, maxBlockSize int) ([]cipher.SHA256, error)
- func (utp *UnconfirmedTxnPool) RemoveInvalid(tx *dbutil.Tx, bc Blockchainer) ([]cipher.SHA256, error)
- func (utp *UnconfirmedTxnPool) RemoveTransactions(tx *dbutil.Tx, txHashes []cipher.SHA256) error
- func (utp *UnconfirmedTxnPool) SetTxnsAnnounced(tx *dbutil.Tx, hashes map[cipher.SHA256]int64) error
- type UnconfirmedTxnPooler
- type Visor
- func (vs *Visor) AddressBalance(head *coin.SignedBlock, auxs coin.AddressUxOuts) (uint64, uint64, error)
- func (vs *Visor) AddressCount() (uint64, error)
- func (vs *Visor) CreateAndExecuteBlock() (coin.SignedBlock, error)
- func (vs *Visor) CreateTransaction(params wallet.CreateTransactionParams) (*coin.Transaction, []wallet.UxBalance, error)
- func (vs *Visor) CreateTransactionDeprecated(wltID string, password []byte, coins uint64, dest cipher.Address) (*coin.Transaction, error)
- func (vs *Visor) ExecuteSignedBlock(b coin.SignedBlock) error
- func (vs *Visor) GenesisPreconditions()
- func (vs Visor) GetAddrUxOuts(address cipher.Address) ([]*historydb.UxOut, error)
- func (vs *Visor) GetAddressTxns(a cipher.Address) ([]Transaction, error)
- func (vs *Visor) GetAllUnconfirmedTxns() ([]UnconfirmedTxn, error)
- func (vs *Visor) GetAllUnspentOutputs() (coin.UxArray, error)
- func (vs *Visor) GetAllValidUnconfirmedTxHashes() ([]cipher.SHA256, error)
- func (vs Visor) GetBalanceOfAddrs(addrs []cipher.Address) ([]wallet.BalancePair, error)
- func (vs *Visor) GetBlock(seq uint64) (*coin.SignedBlock, error)
- func (vs *Visor) GetBlockchainMetadata() (*BlockchainMetadata, error)
- func (vs *Visor) GetBlocks(start, end uint64) ([]coin.SignedBlock, error)
- func (vs Visor) GetHeadBlock() (*coin.SignedBlock, error)
- func (vs Visor) GetHeadBlockTime() (uint64, error)
- func (vs *Visor) GetIncomingOutputs() (coin.UxArray, error)
- func (vs *Visor) GetLastBlocks(num uint64) ([]coin.SignedBlock, error)
- func (vs *Visor) GetSignedBlockByHash(hash cipher.SHA256) (*coin.SignedBlock, error)
- func (vs *Visor) GetSignedBlockBySeq(seq uint64) (*coin.SignedBlock, error)
- func (vs *Visor) GetSignedBlocksSince(seq, ct uint64) ([]coin.SignedBlock, error)
- func (vs *Visor) GetTransaction(txHash cipher.SHA256) (*Transaction, error)
- func (vs *Visor) GetTransactions(flts ...TxFilter) ([]Transaction, error)
- func (vs *Visor) GetUnconfirmedKnown(txns []cipher.SHA256) (coin.Transactions, error)
- func (vs *Visor) GetUnconfirmedTxn(hash cipher.SHA256) (*UnconfirmedTxn, error)
- func (vs *Visor) GetUnconfirmedTxns(filter func(UnconfirmedTxn) bool) ([]UnconfirmedTxn, error)
- func (vs *Visor) GetUnconfirmedUnknown(txns []cipher.SHA256) ([]cipher.SHA256, error)
- func (vs *Visor) GetUnspentOutputs(hashes []cipher.SHA256) (coin.UxArray, error)
- func (vs *Visor) GetUnspentsOfAddrs(addrs []cipher.Address) (coin.AddressUxOuts, error)
- func (vs Visor) GetUxOutByID(id cipher.SHA256) (*historydb.UxOut, error)
- func (vs *Visor) HeadBkSeq() (uint64, bool, error)
- func (vs *Visor) Init() error
- func (vs *Visor) InjectTransaction(txn coin.Transaction) (bool, *ErrTxnViolatesSoftConstraint, error)
- func (vs *Visor) InjectTransactionStrict(txn coin.Transaction) (bool, error)
- func (vs *Visor) RecvOfAddresses(addrs []cipher.Address) (coin.AddressUxOuts, error)
- func (vs *Visor) RefreshUnconfirmed() ([]cipher.SHA256, error)
- func (vs *Visor) RemoveInvalidUnconfirmed() ([]cipher.SHA256, error)
- func (vs *Visor) SetTxnsAnnounced(hashes map[cipher.SHA256]int64) error
- func (vs *Visor) UnconfirmedIncomingOutputs() (coin.UxArray, error)
- func (vs *Visor) UnconfirmedSpendingOutputs() (coin.UxArray, error)
- func (vs *Visor) UnconfirmedSpendsOfAddresses(addrs []cipher.Address) (coin.AddressUxOuts, error)
- func (vs *Visor) VerifyTxnVerbose(txn *coin.Transaction) ([]wallet.UxBalance, bool, error)
Constants ¶
const ( // DebugLevel1 checks for extremely unlikely conditions (10e-40) DebugLevel1 = true // DebugLevel2 enable checks for impossible conditions DebugLevel2 = true )
const ( // MaxCoinSupply is the maximum supply of coins MaxCoinSupply uint64 = 1000000000 // DistributionAddressesTotal is the number of distribution addresses DistributionAddressesTotal uint64 = 100 // DistributionAddressInitialBalance is the initial balance of each distribution address DistributionAddressInitialBalance uint64 = MaxCoinSupply / DistributionAddressesTotal // InitialUnlockedCount is the initial number of unlocked addresses InitialUnlockedCount uint64 = 25 // UnlockAddressRate is the number of addresses to unlock per unlock time interval UnlockAddressRate uint64 = 5 // UnlockTimeInterval is the distribution address unlock time interval, measured in seconds // Once the InitialUnlockedCount is exhausted, // UnlockAddressRate addresses will be unlocked per UnlockTimeInterval UnlockTimeInterval uint64 = 31536000 // in seconds // MaxDropletPrecision represents the decimal precision of droplets MaxDropletPrecision uint64 = 3 //DefaultMaxBlockSize is max block size DefaultMaxBlockSize int = 32768 // in bytes )
Variables ¶
var ( // UnconfirmedTxnsBkt holds unconfirmed transactions UnconfirmedTxnsBkt = []byte("unconfirmed_txns") // UnconfirmedUnspentsBkt holds unconfirmed unspent outputs UnconfirmedUnspentsBkt = []byte("unconfirmed_unspents") )
var (
// BlockchainVerifyTheadNum number of goroutines to use for signature and historydb verification
BlockchainVerifyTheadNum = 4
)
var ( // ErrVerifyStopped is returned when database verification is interrupted ErrVerifyStopped = errors.New("database verification stopped") )
Functions ¶
func CheckDatabase ¶
CheckDatabase checks the database for corruption, rebuild history if corrupted
func CreateBuckets ¶
CreateBuckets creates the buckets used by the blockdb
func DefaultWalker ¶
DefaultWalker default blockchain walker
func DropletPrecisionCheck ¶
DropletPrecisionCheck checks if an amount of coins is valid given decimal place restrictions
func GetDistributionAddresses ¶
func GetDistributionAddresses() []string
GetDistributionAddresses returns a copy of the hardcoded distribution addresses array. Each address has 1,000,000 coins. There are 100 addresses.
func GetLockedDistributionAddresses ¶
func GetLockedDistributionAddresses() []string
GetLockedDistributionAddresses returns distribution addresses that are locked, i.e. they have unspendable outputs
func GetUnlockedDistributionAddresses ¶
func GetUnlockedDistributionAddresses() []string
GetUnlockedDistributionAddresses returns distribution addresses that are unlocked, i.e. they have spendable outputs
func MaxDropletDivisor ¶
func MaxDropletDivisor() uint64
MaxDropletDivisor represents the modulus divisor when checking droplet precision rules.
func NewErrTxnViolatesHardConstraint ¶
NewErrTxnViolatesHardConstraint creates ErrTxnViolatesHardConstraint
func NewErrTxnViolatesSoftConstraint ¶
NewErrTxnViolatesSoftConstraint creates ErrTxnViolatesSoftConstraint
func NewErrTxnViolatesUserConstraint ¶
NewErrTxnViolatesUserConstraint creates ErrTxnViolatesUserConstraint
func ReadableOutputsToUxBalances ¶
func ReadableOutputsToUxBalances(ros ReadableOutputs) ([]wallet.UxBalance, error)
ReadableOutputsToUxBalances converts ReadableOutputs to []wallet.UxBalance
func RepairCorruptDB ¶
RepairCorruptDB checks the database for corruption and if corrupted and is ErrMissingSignature, then then it erases the db and starts over. If it's ErrHistoryDBCorrupted, then rebuild historydb from scratch. A copy of the corrupted database is saved.
func ToAddresses ¶
func ToAddresses(addresses []cipher.Address) func(UnconfirmedTxn) bool
ToAddresses represents a filter that check if tx has output to the given addresses
func TransactionIsLocked ¶
TransactionIsLocked returns true if the transaction spends locked outputs
func TransactionToJSON ¶
func TransactionToJSON(tx coin.Transaction) (string, error)
TransactionToJSON convert transaction to json string TODO -- remove in favor of ReadableTransaction?
func VerifyBlockTxnConstraints ¶
func VerifyBlockTxnConstraints(txn coin.Transaction, head *coin.SignedBlock, uxIn coin.UxArray) error
VerifyBlockTxnConstraints returns an error if any "hard" constraints are violated. "hard" constraints are always enforced and if violated the transaction should not be included in any block and any block that includes such a transaction should be rejected. Checks:
- That the inputs to the transaction exist
- That the transaction does not create or destroy coins
- That the signatures on the transaction are valid
- That there are no duplicate ux inputs
- That there are no duplicate outputs
- That the transaction input and output coins do not overflow uint64
- That the transaction input hours do not overflow uint64
NOTE: Double spends are checked against the unspent output pool when querying for uxIn NOTE: output hours overflow is treated as a soft constraint for transactions inside of a block, due to a bug
which allowed some blocks to be published with overflowing output hours.
func VerifySingleTxnHardConstraints ¶
func VerifySingleTxnHardConstraints(txn coin.Transaction, head *coin.SignedBlock, uxIn coin.UxArray) error
VerifySingleTxnHardConstraints returns an error if any "hard" constraints are violated. "hard" constraints are always enforced and if violated the transaction should not be included in any block and any block that includes such a transaction should be rejected. Checks:
- That the inputs to the transaction exist
- That the transaction does not create or destroy coins
- That the signatures on the transaction are valid
- That there are no duplicate ux inputs
- That there are no duplicate outputs
- That the transaction input and output coins do not overflow uint64
- That the transaction input and output hours do not overflow uint64
NOTE: Double spends are checked against the unspent output pool when querying for uxIn
func VerifySingleTxnSoftConstraints ¶
func VerifySingleTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.UxArray, maxSize int) error
VerifySingleTxnSoftConstraints returns an error if any "soft" constraint are violated. "soft" constaints are enforced at the network and block publication level, but are not enforced at the blockchain level. Clients will not accept blocks that violate hard constraints, but will accept blocks that violate soft constraints. Checks:
- That the transaction size is not greater than the max block total transaction size
- That the transaction burn enough coin hours (the fee)
- That if that transaction does not spend from a locked distribution address
- That the transaction does not create outputs with a higher decimal precision than is allowed
func VerifySingleTxnUserConstraints ¶
func VerifySingleTxnUserConstraints(txn coin.Transaction) error
VerifySingleTxnUserConstraints applies additional verification for a transaction created by the user. This is distinct from transactions created by other users (i.e. received over the network), and from transactions included in blocks.
Types ¶
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
Blockchain maintains blockchain and provides apis for accessing the chain.
func NewBlockchain ¶
func NewBlockchain(db *dbutil.DB, cfg BlockchainConfig) (*Blockchain, error)
NewBlockchain creates a Blockchain
func (*Blockchain) ExecuteBlock ¶
func (bc *Blockchain) ExecuteBlock(tx *dbutil.Tx, sb *coin.SignedBlock) error
ExecuteBlock attempts to append block to blockchain with *dbutil.Tx
func (Blockchain) GetBlocks ¶
func (bc Blockchain) GetBlocks(tx *dbutil.Tx, start, end uint64) ([]coin.SignedBlock, error)
GetBlocks return blocks whose seq are in the range of start and end.
func (*Blockchain) GetGenesisBlock ¶
func (bc *Blockchain) GetGenesisBlock(tx *dbutil.Tx) (*coin.SignedBlock, error)
GetGenesisBlock returns genesis block
func (Blockchain) GetLastBlocks ¶
func (bc Blockchain) GetLastBlocks(tx *dbutil.Tx, num uint64) ([]coin.SignedBlock, error)
GetLastBlocks return the latest N blocks.
func (*Blockchain) GetSignedBlockByHash ¶
func (bc *Blockchain) GetSignedBlockByHash(tx *dbutil.Tx, hash cipher.SHA256) (*coin.SignedBlock, error)
GetSignedBlockByHash returns block of given hash
func (*Blockchain) GetSignedBlockBySeq ¶
func (bc *Blockchain) GetSignedBlockBySeq(tx *dbutil.Tx, seq uint64) (*coin.SignedBlock, error)
GetSignedBlockBySeq returns block of given seq
func (Blockchain) Head ¶
func (bc Blockchain) Head(tx *dbutil.Tx) (*coin.SignedBlock, error)
Head returns the most recent confirmed block
func (Blockchain) Len ¶
func (bc Blockchain) Len(tx *dbutil.Tx) (uint64, error)
Len returns the length of current blockchain.
func (Blockchain) NewBlock ¶
func (bc Blockchain) NewBlock(tx *dbutil.Tx, txns coin.Transactions, currentTime uint64) (*coin.Block, error)
NewBlock creates a Block given an array of Transactions. Only hard constraints are applied to transactions in the block. The caller of this function should apply any additional soft constraints, and choose which transactions to place into the block.
func (*Blockchain) Time ¶
func (bc *Blockchain) Time(tx *dbutil.Tx) (uint64, error)
Time returns time of last block used as system clock indepedent clock for coin hour calculations TODO: Deprecate
func (Blockchain) TransactionFee ¶
func (bc Blockchain) TransactionFee(tx *dbutil.Tx, headTime uint64) coin.FeeCalculator
TransactionFee calculates the current transaction fee in coinhours of a Transaction
func (*Blockchain) Unspent ¶
func (bc *Blockchain) Unspent() blockdb.UnspentPooler
Unspent returns the unspent outputs pool
func (Blockchain) VerifyBlockTxnConstraints ¶
func (bc Blockchain) VerifyBlockTxnConstraints(tx *dbutil.Tx, txn coin.Transaction) error
VerifyBlockTxnConstraints checks that the transaction does not violate hard constraints, for transactions that are already included in a block.
func (*Blockchain) VerifySignature ¶
func (bc *Blockchain) VerifySignature(block *coin.SignedBlock) error
VerifySignature checks that BlockSigs state correspond with coin.Blockchain state and that all signatures are valid.
func (Blockchain) VerifySingleTxnHardConstraints ¶
func (bc Blockchain) VerifySingleTxnHardConstraints(tx *dbutil.Tx, txn coin.Transaction) error
VerifySingleTxnHardConstraints checks that the transaction does not violate hard constraints. for transactions that are not included in a block.
func (Blockchain) VerifySingleTxnSoftHardConstraints ¶
func (bc Blockchain) VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin.Transaction, maxSize int) error
VerifySingleTxnSoftHardConstraints checks that the transaction does not violate hard or soft constraints, for transactions that are not included in a block. Hard constraints are checked before soft constraints.
func (*Blockchain) WalkChain ¶
func (bc *Blockchain) WalkChain(workers int, f func(*dbutil.Tx, *coin.SignedBlock) error, quit chan struct{}) error
WalkChain walk through the blockchain concurrently The quit channel is optional and if closed, this method still stop.
type BlockchainConfig ¶
type BlockchainConfig struct {
// Arbitrating mode: if in arbitrating mode, when master node execute blocks,
// the invalid transaction will be skipped and continue the next; otherwise,
// node will throw the error and return.
Arbitrating bool
Pubkey cipher.PubKey
}
BlockchainConfig configures Blockchain options
type BlockchainMetadata ¶
type BlockchainMetadata struct {
// Most recent block's header
Head ReadableBlockHeader `json:"head"`
// Number of unspent outputs in the coin.Blockchain
Unspents uint64 `json:"unspents"`
// Number of known unconfirmed txns
Unconfirmed uint64 `json:"unconfirmed"`
}
BlockchainMetadata encapsulates useful information from the coin.Blockchain
func NewBlockchainMetadata ¶
func NewBlockchainMetadata(head *coin.SignedBlock, unconfirmedLen, unspentsLen uint64) (*BlockchainMetadata, error)
NewBlockchainMetadata creates blockchain meta data
type Blockchainer ¶
type Blockchainer interface {
GetGenesisBlock(tx *dbutil.Tx) (*coin.SignedBlock, error)
GetBlocks(tx *dbutil.Tx, start, end uint64) ([]coin.SignedBlock, error)
GetLastBlocks(tx *dbutil.Tx, n uint64) ([]coin.SignedBlock, error)
GetSignedBlockByHash(tx *dbutil.Tx, hash cipher.SHA256) (*coin.SignedBlock, error)
GetSignedBlockBySeq(tx *dbutil.Tx, seq uint64) (*coin.SignedBlock, error)
Unspent() blockdb.UnspentPooler
Len(tx *dbutil.Tx) (uint64, error)
Head(tx *dbutil.Tx) (*coin.SignedBlock, error)
HeadSeq(tx *dbutil.Tx) (uint64, bool, error)
Time(tx *dbutil.Tx) (uint64, error)
NewBlock(tx *dbutil.Tx, txns coin.Transactions, currentTime uint64) (*coin.Block, error)
ExecuteBlock(tx *dbutil.Tx, sb *coin.SignedBlock) error
VerifyBlockTxnConstraints(tx *dbutil.Tx, txn coin.Transaction) error
VerifySingleTxnHardConstraints(tx *dbutil.Tx, txn coin.Transaction) error
VerifySingleTxnSoftHardConstraints(tx *dbutil.Tx, txn coin.Transaction, maxSize int) error
TransactionFee(tx *dbutil.Tx, hours uint64) coin.FeeCalculator
}
Blockchainer is the interface that provides methods for accessing the blockchain data
type BuildInfo ¶
type BuildInfo struct {
Version string `json:"version"` // version number
Commit string `json:"commit"` // git commit id
Branch string `json:"branch"` // git branch name
}
BuildInfo represents the build info
type Config ¶
type Config struct {
// Is this the master blockchain
IsMaster bool
//Public key of blockchain authority
BlockchainPubkey cipher.PubKey
//Secret key of blockchain authority (if master)
BlockchainSeckey cipher.SecKey
// Maximum size of a block, in bytes.
MaxBlockSize int
// Where the blockchain is saved
BlockchainFile string
// Where the block signatures are saved
BlockSigsFile string
//address for genesis
GenesisAddress cipher.Address
// Genesis block sig
GenesisSignature cipher.Sig
// Genesis block timestamp
GenesisTimestamp uint64
// Number of coins in genesis block
GenesisCoinVolume uint64
// bolt db file path
DBPath string
// enable arbitrating mode
Arbitrating bool
// wallet directory
WalletDirectory string
// build info, including version, build time etc.
BuildInfo BuildInfo
// enables wallet API
EnableWalletAPI bool
// enables seed API
EnableSeedAPI bool
// wallet crypto type
WalletCryptoType wallet.CryptoType
}
Config configuration parameters for the Visor
func NewVisorConfig ¶
func NewVisorConfig() Config
NewVisorConfig put cap on block size, not on transactions/block Skycoin transactions are smaller than Bitcoin transactions so skycoin has a higher transactions per second for the same block size
type ErrCorruptDB ¶
type ErrCorruptDB struct {
// contains filtered or unexported fields
}
ErrCorruptDB is returned if the database is corrupted The original corruption error is embedded
type ErrTxnViolatesHardConstraint ¶
type ErrTxnViolatesHardConstraint struct {
Err error
}
ErrTxnViolatesHardConstraint is returned when a transaction violates hard constraints
func (ErrTxnViolatesHardConstraint) Error ¶
func (e ErrTxnViolatesHardConstraint) Error() string
type ErrTxnViolatesSoftConstraint ¶
type ErrTxnViolatesSoftConstraint struct {
Err error
}
ErrTxnViolatesSoftConstraint is returned when a transaction violates soft constraints
func (ErrTxnViolatesSoftConstraint) Error ¶
func (e ErrTxnViolatesSoftConstraint) Error() string
type ErrTxnViolatesUserConstraint ¶
type ErrTxnViolatesUserConstraint struct {
Err error
}
ErrTxnViolatesUserConstraint is returned when a transaction violates user constraints
func (ErrTxnViolatesUserConstraint) Error ¶
func (e ErrTxnViolatesUserConstraint) Error() string
type Historyer ¶
type Historyer interface {
GetUxOuts(tx *dbutil.Tx, uxids []cipher.SHA256) ([]*historydb.UxOut, error)
ParseBlock(tx *dbutil.Tx, b coin.Block) error
GetTransaction(tx *dbutil.Tx, hash cipher.SHA256) (*historydb.Transaction, error)
GetAddrUxOuts(tx *dbutil.Tx, address cipher.Address) ([]*historydb.UxOut, error)
GetAddressTxns(tx *dbutil.Tx, address cipher.Address) ([]historydb.Transaction, error)
NeedsReset(tx *dbutil.Tx) (bool, error)
Erase(tx *dbutil.Tx) error
ParsedBlockSeq(tx *dbutil.Tx) (uint64, bool, error)
ForEachTxn(tx *dbutil.Tx, f func(cipher.SHA256, *historydb.Transaction) error) error
}
Historyer is the interface that provides methods for accessing history data that are parsed from blockchain.
type ReadableBlock ¶
type ReadableBlock struct {
Head ReadableBlockHeader `json:"header"`
Body ReadableBlockBody `json:"body"`
Size int `json:"size"`
}
ReadableBlock represents readable block
func NewReadableBlock ¶
func NewReadableBlock(b *coin.Block) (*ReadableBlock, error)
NewReadableBlock creates readable block
type ReadableBlockBody ¶
type ReadableBlockBody struct {
Transactions []ReadableTransaction `json:"txns"`
}
ReadableBlockBody represents readable block body
func NewReadableBlockBody ¶
func NewReadableBlockBody(b *coin.Block) (*ReadableBlockBody, error)
NewReadableBlockBody creates readable block body
type ReadableBlockHeader ¶
type ReadableBlockHeader struct {
BkSeq uint64 `json:"seq"`
BlockHash string `json:"block_hash"`
PreviousBlockHash string `json:"previous_block_hash"`
Time uint64 `json:"timestamp"`
Fee uint64 `json:"fee"`
Version uint32 `json:"version"`
BodyHash string `json:"tx_body_hash"`
}
ReadableBlockHeader represents the readable block header
func NewReadableBlockHeader ¶
func NewReadableBlockHeader(b *coin.BlockHeader) ReadableBlockHeader
NewReadableBlockHeader creates readable block header
type ReadableBlocks ¶
type ReadableBlocks struct {
Blocks []ReadableBlock `json:"blocks"`
}
ReadableBlocks an array of readable blocks.
func NewReadableBlocks ¶
func NewReadableBlocks(blocks []coin.SignedBlock) (*ReadableBlocks, error)
NewReadableBlocks converts []coin.SignedBlock to readable blocks
type ReadableOutput ¶
type ReadableOutput struct {
Hash string `json:"hash"`
Time uint64 `json:"time"`
BkSeq uint64 `json:"block_seq"`
SourceTransaction string `json:"src_tx"`
Address string `json:"address"`
Coins string `json:"coins"`
Hours uint64 `json:"hours"`
CalculatedHours uint64 `json:"calculated_hours"`
}
ReadableOutput represents readable output
func NewReadableOutput ¶
func NewReadableOutput(headTime uint64, t coin.UxOut) (ReadableOutput, error)
NewReadableOutput creates readable output
type ReadableOutputSet ¶
type ReadableOutputSet struct {
// HeadOutputs are unspent outputs confirmed in the blockchain
HeadOutputs ReadableOutputs `json:"head_outputs"`
// IncomingOutputs are unspent outputs being spent in unconfirmed transactions
OutgoingOutputs ReadableOutputs `json:"outgoing_outputs"`
// IncomingOutputs are unspent outputs being created by unconfirmed transactions
IncomingOutputs ReadableOutputs `json:"incoming_outputs"`
}
ReadableOutputSet records unspent outputs in different status.
func (ReadableOutputSet) AggregateUnspentOutputs ¶
func (os ReadableOutputSet) AggregateUnspentOutputs() (map[string]uint64, error)
AggregateUnspentOutputs builds a map from address to coins
func (ReadableOutputSet) ExpectedOutputs ¶
func (os ReadableOutputSet) ExpectedOutputs() ReadableOutputs
ExpectedOutputs adds IncomingOutputs to SpendableOutputs
func (ReadableOutputSet) SpendableOutputs ¶
func (os ReadableOutputSet) SpendableOutputs() ReadableOutputs
SpendableOutputs subtracts OutgoingOutputs from HeadOutputs
type ReadableOutputs ¶
type ReadableOutputs []ReadableOutput
ReadableOutputs slice of ReadableOutput provids method to calculate balance
func NewReadableOutputs ¶
func NewReadableOutputs(headTime uint64, uxs coin.UxArray) (ReadableOutputs, error)
NewReadableOutputs converts unspent outputs to readable output
type ReadableTransaction ¶
type ReadableTransaction struct {
Length uint32 `json:"length"`
Type uint8 `json:"type"`
Hash string `json:"txid"`
InnerHash string `json:"inner_hash"`
Timestamp uint64 `json:"timestamp,omitempty"`
Sigs []string `json:"sigs"`
In []string `json:"inputs"`
Out []ReadableTransactionOutput `json:"outputs"`
}
ReadableTransaction represents readable transaction
func NewReadableTransaction ¶
func NewReadableTransaction(t *Transaction) (*ReadableTransaction, error)
NewReadableTransaction creates readable transaction
type ReadableTransactionInput ¶
type ReadableTransactionInput struct {
Hash string `json:"uxid"`
Address string `json:"owner"`
Coins string `json:"coins"`
Hours uint64 `json:"hours"`
CalculatedHours uint64 `json:"calculated_hours"`
}
ReadableTransactionInput readable transaction input
func NewReadableTransactionInput ¶
func NewReadableTransactionInput(ux coin.UxOut, calculateHoursTime uint64) (*ReadableTransactionInput, error)
NewReadableTransactionInput creates ReadableTransactionInput
type ReadableTransactionOutput ¶
type ReadableTransactionOutput struct {
Hash string `json:"uxid"`
Address string `json:"dst"`
Coins string `json:"coins"`
Hours uint64 `json:"hours"`
}
ReadableTransactionOutput readable transaction output
func NewReadableTransactionOutput ¶
func NewReadableTransactionOutput(t *coin.TransactionOutput, txid cipher.SHA256) (*ReadableTransactionOutput, error)
NewReadableTransactionOutput creates ReadableTransactionOutput
type ReadableUnconfirmedTxn ¶
type ReadableUnconfirmedTxn struct {
Txn ReadableTransaction `json:"transaction"`
Received time.Time `json:"received"`
Checked time.Time `json:"checked"`
Announced time.Time `json:"announced"`
IsValid bool `json:"is_valid"`
}
ReadableUnconfirmedTxn represents readable unconfirmed transaction
func NewReadableUnconfirmedTxn ¶
func NewReadableUnconfirmedTxn(unconfirmed *UnconfirmedTxn) (*ReadableUnconfirmedTxn, error)
NewReadableUnconfirmedTxn creates readable unconfirmed transaction
func NewReadableUnconfirmedTxns ¶
func NewReadableUnconfirmedTxns(txs []UnconfirmedTxn) ([]ReadableUnconfirmedTxn, error)
NewReadableUnconfirmedTxns converts []UnconfirmedTxn to []ReadableUnconfirmedTxn
type Richlist ¶
type Richlist []RichlistBalance
Richlist contains RichlistBalances
func NewRichlist ¶
NewRichlist create Richlist via unspent outputs map
func (Richlist) FilterAddresses ¶
FilterAddresses returns the richlist without addresses from the map
type RichlistBalance ¶
type RichlistBalance struct {
Address string `json:"address"`
Coins string `json:"coins"`
Locked bool `json:"locked"`
// contains filtered or unexported fields
}
RichlistBalance holds info an address balance holder
type Transaction ¶
type Transaction struct {
Txn coin.Transaction //`json:"txn"`
Status TransactionStatus //`json:"status"`
Time uint64 //`json:"time"`
}
Transaction wraps around coin.Transaction, tagged with its status. This allows us to include unconfirmed txns
type TransactionJSON ¶
type TransactionJSON struct {
Hash string `json:"hash"`
InnerHash string `json:"inner_hash"`
Sigs []string `json:"sigs"`
In []string `json:"in"`
Out []TransactionOutputJSON `json:"out"`
}
TransactionJSON represents transaction in json
type TransactionOutputJSON ¶
type TransactionOutputJSON struct {
Hash string `json:"hash"`
SourceTransaction string `json:"src_tx"`
Address string `json:"address"` // Address of receiver
Coins string `json:"coins"` // Number of coins
Hours uint64 `json:"hours"` // Coin hours
}
TransactionOutputJSON represents the transaction output json
func NewTxOutputJSON ¶
func NewTxOutputJSON(ux coin.TransactionOutput, srcTx cipher.SHA256) (*TransactionOutputJSON, error)
NewTxOutputJSON creates transaction output json
type TransactionStatus ¶
type TransactionStatus struct {
Confirmed bool `json:"confirmed"`
// This txn is in the unconfirmed pool
Unconfirmed bool `json:"unconfirmed"`
// If confirmed, how many blocks deep in the chain it is. Will be at least
// 1 if confirmed.
Height uint64 `json:"height"`
// Execute block seq
BlockSeq uint64 `json:"block_seq"`
// We can't find anything about this txn. Be aware that the txn may be
// in someone else's unconfirmed pool, and if valid, it may become a
// confirmed txn in the future
Unknown bool `json:"unknown"`
}
TransactionStatus represents the transaction status
func NewConfirmedTransactionStatus ¶
func NewConfirmedTransactionStatus(height uint64, blockSeq uint64) TransactionStatus
NewConfirmedTransactionStatus creates confirmed transaction status
func NewUnconfirmedTransactionStatus ¶
func NewUnconfirmedTransactionStatus() TransactionStatus
NewUnconfirmedTransactionStatus creates unconfirmed transaction status
func NewUnknownTransactionStatus ¶
func NewUnknownTransactionStatus() TransactionStatus
NewUnknownTransactionStatus creates unknow transaction status
type TxFilter ¶
type TxFilter interface {
// Returns whether the transaction is matched
Match(*Transaction) bool
}
TxFilter transaction filter type
func AddrsFilter ¶
AddrsFilter collects all addresses related transactions.
func ConfirmedTxFilter ¶
ConfirmedTxFilter collects the transaction whose 'Confirmed' status matchs the parameter passed in.
type TxnUnspents ¶
TxnUnspents maps from coin.Transaction hash to its expected unspents. The unspents' Head can be different at execution time, but the Unspent's hash is fixed.
func (TxnUnspents) AllForAddress ¶
func (tus TxnUnspents) AllForAddress(a cipher.Address) coin.UxArray
AllForAddress returns all Unspents for a single address
type UnconfirmedTxn ¶
type UnconfirmedTxn struct {
Txn coin.Transaction
// Time the txn was last received
Received int64
// Time the txn was last checked against the blockchain
Checked int64
// Last time we announced this txn
Announced int64
// If this txn is valid
IsValid int8
}
UnconfirmedTxn unconfirmed transaction
func (*UnconfirmedTxn) Hash ¶
func (ut *UnconfirmedTxn) Hash() cipher.SHA256
Hash returns the coin.Transaction's hash
type UnconfirmedTxnPool ¶
type UnconfirmedTxnPool struct {
// contains filtered or unexported fields
}
UnconfirmedTxnPool manages unconfirmed transactions
func NewUnconfirmedTxnPool ¶
func NewUnconfirmedTxnPool(db *dbutil.DB) (*UnconfirmedTxnPool, error)
NewUnconfirmedTxnPool creates an UnconfirmedTxnPool instance
func (*UnconfirmedTxnPool) ForEach ¶
func (utp *UnconfirmedTxnPool) ForEach(tx *dbutil.Tx, f func(cipher.SHA256, UnconfirmedTxn) error) error
ForEach iterate the pool with given callback function
func (*UnconfirmedTxnPool) Get ¶
func (utp *UnconfirmedTxnPool) Get(tx *dbutil.Tx, hash cipher.SHA256) (*UnconfirmedTxn, error)
Get returns the unconfirmed transaction of given tx hash.
func (*UnconfirmedTxnPool) GetIncomingOutputs ¶
func (utp *UnconfirmedTxnPool) GetIncomingOutputs(tx *dbutil.Tx, bh coin.BlockHeader) (coin.UxArray, error)
GetIncomingOutputs returns all predicted incoming outputs.
func (*UnconfirmedTxnPool) GetKnown ¶
func (utp *UnconfirmedTxnPool) GetKnown(tx *dbutil.Tx, txns []cipher.SHA256) (coin.Transactions, error)
GetKnown returns all known coin.Transactions from the pool, given hashes to select
func (*UnconfirmedTxnPool) GetTxHashes ¶
func (utp *UnconfirmedTxnPool) GetTxHashes(tx *dbutil.Tx, filter func(UnconfirmedTxn) bool) ([]cipher.SHA256, error)
GetTxHashes returns transaction hashes that can pass the filter
func (*UnconfirmedTxnPool) GetTxns ¶
func (utp *UnconfirmedTxnPool) GetTxns(tx *dbutil.Tx, filter func(UnconfirmedTxn) bool) ([]UnconfirmedTxn, error)
GetTxns returns all transactions that can pass the filter
func (*UnconfirmedTxnPool) GetUnknown ¶
func (utp *UnconfirmedTxnPool) GetUnknown(tx *dbutil.Tx, txns []cipher.SHA256) ([]cipher.SHA256, error)
GetUnknown returns txn hashes with known ones removed
func (*UnconfirmedTxnPool) GetUnspentsOfAddr ¶
func (utp *UnconfirmedTxnPool) GetUnspentsOfAddr(tx *dbutil.Tx, addr cipher.Address) (coin.UxArray, error)
GetUnspentsOfAddr returns unspent outputs of given address in unspent tx pool
func (*UnconfirmedTxnPool) InjectTransaction ¶
func (utp *UnconfirmedTxnPool) InjectTransaction(tx *dbutil.Tx, bc Blockchainer, txn coin.Transaction, maxSize int) (bool, *ErrTxnViolatesSoftConstraint, error)
InjectTransaction adds a coin.Transaction to the pool, or updates an existing one's timestamps Returns an error if txn is invalid, and whether the transaction already existed in the pool. If the transaction violates hard constraints, it is rejected. Soft constraints violations mark a txn as invalid, but the txn is inserted. The soft violation is returned.
func (*UnconfirmedTxnPool) Len ¶
func (utp *UnconfirmedTxnPool) Len(tx *dbutil.Tx) (uint64, error)
Len returns the number of unconfirmed transactions
func (*UnconfirmedTxnPool) RawTxns ¶
func (utp *UnconfirmedTxnPool) RawTxns(tx *dbutil.Tx) (coin.Transactions, error)
RawTxns returns underlying coin.Transactions
func (*UnconfirmedTxnPool) RecvOfAddresses ¶
func (utp *UnconfirmedTxnPool) RecvOfAddresses(tx *dbutil.Tx, bh coin.BlockHeader, addrs []cipher.Address) (coin.AddressUxOuts, error)
RecvOfAddresses returns unconfirmed receiving uxouts of addresses
func (*UnconfirmedTxnPool) Refresh ¶
func (utp *UnconfirmedTxnPool) Refresh(tx *dbutil.Tx, bc Blockchainer, maxBlockSize int) ([]cipher.SHA256, error)
Refresh checks all unconfirmed txns against the blockchain. If the transaction becomes invalid it is marked invalid. If the transaction becomes valid it is marked valid and is returned to the caller.
func (*UnconfirmedTxnPool) RemoveInvalid ¶
func (utp *UnconfirmedTxnPool) RemoveInvalid(tx *dbutil.Tx, bc Blockchainer) ([]cipher.SHA256, error)
RemoveInvalid checks all unconfirmed txns against the blockchain. If a transaction violates hard constraints it is removed from the pool. The transactions that were removed are returned.
func (*UnconfirmedTxnPool) RemoveTransactions ¶
RemoveTransactions remove transactions with dbutil.Tx
func (*UnconfirmedTxnPool) SetTxnsAnnounced ¶
func (utp *UnconfirmedTxnPool) SetTxnsAnnounced(tx *dbutil.Tx, hashes map[cipher.SHA256]int64) error
SetTxnsAnnounced updates announced time of specific tx
type UnconfirmedTxnPooler ¶
type UnconfirmedTxnPooler interface {
SetTxnsAnnounced(tx *dbutil.Tx, hashes map[cipher.SHA256]int64) error
InjectTransaction(tx *dbutil.Tx, bc Blockchainer, t coin.Transaction, maxSize int) (bool, *ErrTxnViolatesSoftConstraint, error)
RawTxns(tx *dbutil.Tx) (coin.Transactions, error)
RemoveTransactions(tx *dbutil.Tx, txns []cipher.SHA256) error
Refresh(tx *dbutil.Tx, bc Blockchainer, maxBlockSize int) ([]cipher.SHA256, error)
RemoveInvalid(tx *dbutil.Tx, bc Blockchainer) ([]cipher.SHA256, error)
GetUnknown(tx *dbutil.Tx, txns []cipher.SHA256) ([]cipher.SHA256, error)
GetKnown(tx *dbutil.Tx, txns []cipher.SHA256) (coin.Transactions, error)
RecvOfAddresses(tx *dbutil.Tx, bh coin.BlockHeader, addrs []cipher.Address) (coin.AddressUxOuts, error)
GetIncomingOutputs(tx *dbutil.Tx, bh coin.BlockHeader) (coin.UxArray, error)
Get(tx *dbutil.Tx, hash cipher.SHA256) (*UnconfirmedTxn, error)
GetTxns(tx *dbutil.Tx, filter func(tx UnconfirmedTxn) bool) ([]UnconfirmedTxn, error)
GetTxHashes(tx *dbutil.Tx, filter func(tx UnconfirmedTxn) bool) ([]cipher.SHA256, error)
ForEach(tx *dbutil.Tx, f func(cipher.SHA256, UnconfirmedTxn) error) error
GetUnspentsOfAddr(tx *dbutil.Tx, addr cipher.Address) (coin.UxArray, error)
Len(tx *dbutil.Tx) (uint64, error)
}
UnconfirmedTxnPooler is the interface that provides methods for accessing the unconfirmed transaction pool
type Visor ¶
type Visor struct {
Config Config
DB *dbutil.DB
// Unconfirmed transactions, held for relay until we get block confirmation
Unconfirmed UnconfirmedTxnPooler
Blockchain Blockchainer
Wallets *wallet.Service
StartedAt time.Time
// contains filtered or unexported fields
}
Visor manages the Blockchain as both a Master and a Normal
func (*Visor) AddressBalance ¶
func (vs *Visor) AddressBalance(head *coin.SignedBlock, auxs coin.AddressUxOuts) (uint64, uint64, error)
AddressBalance computes the total balance for cipher.Addresses and their coin.UxOuts
func (*Visor) AddressCount ¶
AddressCount returns the total number of addresses with unspents
func (*Visor) CreateAndExecuteBlock ¶
func (vs *Visor) CreateAndExecuteBlock() (coin.SignedBlock, error)
CreateAndExecuteBlock creates a SignedBlock from pending transactions and executes it
func (*Visor) CreateTransaction ¶
func (vs *Visor) CreateTransaction(params wallet.CreateTransactionParams) (*coin.Transaction, []wallet.UxBalance, error)
CreateTransaction creates a transaction based upon the parameters in wallet.CreateTransactionParams
func (*Visor) CreateTransactionDeprecated ¶
func (vs *Visor) CreateTransactionDeprecated(wltID string, password []byte, coins uint64, dest cipher.Address) (*coin.Transaction, error)
CreateTransactionDeprecated creates a transaction using an entire wallet, specifying only coins and one destination
func (*Visor) ExecuteSignedBlock ¶
func (vs *Visor) ExecuteSignedBlock(b coin.SignedBlock) error
ExecuteSignedBlock adds a block to the blockchain, or returns error. Blocks must be executed in sequence, and be signed by the master server
func (*Visor) GenesisPreconditions ¶
func (vs *Visor) GenesisPreconditions()
GenesisPreconditions panics if conditions for genesis block are not met
func (Visor) GetAddrUxOuts ¶
GetAddrUxOuts gets all the address affected UxOuts.
func (*Visor) GetAddressTxns ¶
func (vs *Visor) GetAddressTxns(a cipher.Address) ([]Transaction, error)
GetAddressTxns returns the Transactions whose unspents give coins to a cipher.Address. This includes unconfirmed txns' predicted unspents.
func (*Visor) GetAllUnconfirmedTxns ¶
func (vs *Visor) GetAllUnconfirmedTxns() ([]UnconfirmedTxn, error)
GetAllUnconfirmedTxns returns all unconfirmed transactions
func (*Visor) GetAllUnspentOutputs ¶
GetAllUnspentOutputs returns all unspent outputs
func (*Visor) GetAllValidUnconfirmedTxHashes ¶
GetAllValidUnconfirmedTxHashes returns all valid unconfirmed transaction hashes
func (Visor) GetBalanceOfAddrs ¶
GetBalanceOfAddrs returns balance pairs of given addreses
func (*Visor) GetBlock ¶
func (vs *Visor) GetBlock(seq uint64) (*coin.SignedBlock, error)
GetBlock returns a copy of the block at seq. Returns error if seq out of range
func (*Visor) GetBlockchainMetadata ¶
func (vs *Visor) GetBlockchainMetadata() (*BlockchainMetadata, error)
GetBlockchainMetadata returns descriptive Blockchain information
func (*Visor) GetBlocks ¶
func (vs *Visor) GetBlocks(start, end uint64) ([]coin.SignedBlock, error)
GetBlocks returns multiple blocks between start and end (not including end). Returns empty slice if unable to fulfill request, it does not return nil.
func (Visor) GetHeadBlock ¶
func (vs Visor) GetHeadBlock() (*coin.SignedBlock, error)
GetHeadBlock gets head block.
func (Visor) GetHeadBlockTime ¶
GetHeadBlockTime returns the time of the head block.
func (*Visor) GetIncomingOutputs ¶
GetIncomingOutputs returns all predicted outputs that are in pending tx pool
func (*Visor) GetLastBlocks ¶
func (vs *Visor) GetLastBlocks(num uint64) ([]coin.SignedBlock, error)
GetLastBlocks returns last N blocks
func (*Visor) GetSignedBlockByHash ¶
GetSignedBlockByHash get block of specific hash header, return nil on not found.
func (*Visor) GetSignedBlockBySeq ¶
func (vs *Visor) GetSignedBlockBySeq(seq uint64) (*coin.SignedBlock, error)
GetSignedBlockBySeq get block of specific seq, return nil on not found.
func (*Visor) GetSignedBlocksSince ¶
func (vs *Visor) GetSignedBlocksSince(seq, ct uint64) ([]coin.SignedBlock, error)
GetSignedBlocksSince returns N signed blocks more recent than Seq. Does not return nil.
func (*Visor) GetTransaction ¶
func (vs *Visor) GetTransaction(txHash cipher.SHA256) (*Transaction, error)
GetTransaction returns a Transaction by hash.
func (*Visor) GetTransactions ¶
func (vs *Visor) GetTransactions(flts ...TxFilter) ([]Transaction, error)
GetTransactions returns transactions that can pass the filters. If any 'AddrsFilter' exist, call vs.getTransactionsOfAddrs, cause there's an address index of transactions in db which, having address as key and transaction hashes as value. If no filters is provided, returns all transactions.
func (*Visor) GetUnconfirmedKnown ¶
GetUnconfirmedKnown returns unconfirmed txn hashes with known ones removed
func (*Visor) GetUnconfirmedTxn ¶
func (vs *Visor) GetUnconfirmedTxn(hash cipher.SHA256) (*UnconfirmedTxn, error)
GetUnconfirmedTxn gets an unconfirmed transaction from the DB
func (*Visor) GetUnconfirmedTxns ¶
func (vs *Visor) GetUnconfirmedTxns(filter func(UnconfirmedTxn) bool) ([]UnconfirmedTxn, error)
GetUnconfirmedTxns gets all confirmed transactions of specific addresses
func (*Visor) GetUnconfirmedUnknown ¶
GetUnconfirmedUnknown returns unconfirmed txn hashes with known ones removed
func (*Visor) GetUnspentOutputs ¶
GetUnspentOutputs returns unspent outputs from the pool, queried by hashes. If any do not exist, ErrUnspentNotExist is returned
func (*Visor) GetUnspentsOfAddrs ¶
GetUnspentsOfAddrs returns unspent outputs of multiple addresses
func (Visor) GetUxOutByID ¶
GetUxOutByID gets UxOut by hash id.
func (*Visor) HeadBkSeq ¶
HeadBkSeq returns the highest BkSeq we know, returns false in the 2nd return value if the blockchain is empty
func (*Visor) InjectTransaction ¶
func (vs *Visor) InjectTransaction(txn coin.Transaction) (bool, *ErrTxnViolatesSoftConstraint, error)
InjectTransaction records a coin.Transaction to the UnconfirmedTxnPool if the txn is not already in the blockchain. The bool return value is whether or not the transaction was already in the pool. If the transaction violates hard constraints, it is rejected, and error will not be nil. If the transaction only violates soft constraints, it is still injected, and the soft constraint violation is returned.
func (*Visor) InjectTransactionStrict ¶
func (vs *Visor) InjectTransactionStrict(txn coin.Transaction) (bool, error)
InjectTransactionStrict records a coin.Transaction to the UnconfirmedTxnPool if the txn is not already in the blockchain. The bool return value is whether or not the transaction was already in the pool. If the transaction violates hard or soft constraints, it is rejected, and error will not be nil.
func (*Visor) RecvOfAddresses ¶
RecvOfAddresses returns unconfirmed receiving uxouts of addresses
func (*Visor) RefreshUnconfirmed ¶
RefreshUnconfirmed checks unconfirmed txns against the blockchain and returns all transaction that turn to valid.
func (*Visor) RemoveInvalidUnconfirmed ¶
RemoveInvalidUnconfirmed removes transactions that become permanently invalid (by violating hard constraints) from the pool. Returns the transaction hashes that were removed.
func (*Visor) SetTxnsAnnounced ¶
SetTxnsAnnounced updates announced time of specific tx
func (*Visor) UnconfirmedIncomingOutputs ¶
UnconfirmedIncomingOutputs returns all predicted outputs that are in pending tx pool
func (*Visor) UnconfirmedSpendingOutputs ¶
UnconfirmedSpendingOutputs returns all spending outputs in unconfirmed tx pool
func (*Visor) UnconfirmedSpendsOfAddresses ¶
UnconfirmedSpendsOfAddresses returns all unconfirmed coin.UxOut spends of addresses
func (*Visor) VerifyTxnVerbose ¶
VerifyTxnVerbose verifies a transaction, it returns transaction's input uxouts, whether the transaction is confirmed, and error if any