コード例 #1
0
ファイル: unconfirmed.go プロジェクト: up4k/skycoin
// Performs additional transaction verification at the unconfirmed pool level.
// This checks tunable parameters that should prevent the transaction from
// entering the blockchain, but cannot be done at the blockchain level because
// they may be changed.
func VerifyTransaction(bc *coin.Blockchain, t *coin.Transaction, maxSize int,
	burnFactor uint64) error {
	if t.Size() > maxSize {
		return errors.New("Transaction too large")
	}
	if fee, err := bc.TransactionFee(t); err != nil {
		return err
	} else if burnFactor != 0 && t.OutputHours()/burnFactor > fee {
		return errors.New("Transaction fee minimum not met")
	}
	return nil
}
コード例 #2
0
ファイル: unconfirmed.go プロジェクト: Chao-Jia/skycoin
// Performs additional transaction verification at the unconfirmed pool level.
// This checks tunable parameters that should prevent the transaction from
// entering the blockchain, but cannot be done at the blockchain level because
// they may be changed.
func VerifyTransactionFee(bc *coin.Blockchain, t *coin.Transaction) error {
	fee, err := bc.TransactionFee(t)
	if err != nil {
		return err
	}

	//calculate total number of coinhours
	var total uint64 = t.OutputHours() + fee
	//make sure at least half the coin hours are destroyed
	if fee < total/BurnFactor {
		return errors.New("Transaction coinhour fee minimum not met")
	}
	return nil
}