forked from dominant-strategies/go-quai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial utxo types, db methods, and accessors
- Loading branch information
1 parent
29b6242
commit fe63809
Showing
19 changed files
with
903 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package types | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/dominant-strategies/go-quai/common" | ||
) | ||
|
||
type QiTx struct { | ||
ChainID *big.Int // replay protection | ||
TxIn []*TxIn | ||
TxOut []*TxOut | ||
} | ||
|
||
// copy creates a deep copy of the transaction data and initializes all fields. | ||
func (tx *QiTx) copy() TxData { | ||
cpy := &QiTx{ | ||
ChainID: new(big.Int), | ||
} | ||
if tx.ChainID != nil { | ||
cpy.ChainID.Set(tx.ChainID) | ||
} | ||
cpy.TxIn = make([]*TxIn, len(tx.TxIn)) | ||
cpy.TxOut = make([]*TxOut, len(tx.TxOut)) | ||
copy(cpy.TxIn, tx.TxIn) | ||
copy(cpy.TxOut, tx.TxOut) | ||
return cpy | ||
} | ||
|
||
// accessors for innerTx. | ||
func (tx *QiTx) txType() byte { return QiTxType } | ||
func (tx *QiTx) chainID() *big.Int { return tx.ChainID } | ||
func (tx *QiTx) protected() bool { return true } | ||
func (tx *QiTx) accessList() AccessList { panic("Qi TX does not have accessList") } | ||
func (tx *QiTx) data() []byte { panic("Qi TX does not have data") } | ||
func (tx *QiTx) gas() uint64 { panic("Qi TX does not have gas") } | ||
func (tx *QiTx) gasFeeCap() *big.Int { panic("Qi TX does not have gasFeeCap") } | ||
func (tx *QiTx) gasTipCap() *big.Int { panic("Qi TX does not have gasTipCap") } | ||
func (tx *QiTx) gasPrice() *big.Int { panic("Qi TX does not have gasPrice") } | ||
func (tx *QiTx) value() *big.Int { panic("Qi TX does not have value") } | ||
func (tx *QiTx) nonce() uint64 { panic("Qi TX does not have nonce") } | ||
func (tx *QiTx) to() *common.Address { panic("Qi TX does not have to") } | ||
func (tx *QiTx) etxGasLimit() uint64 { panic("Qi TX does not have etxGasLimit") } | ||
func (tx *QiTx) etxGasPrice() *big.Int { panic("Qi TX does not have etxGasPrice") } | ||
func (tx *QiTx) etxGasTip() *big.Int { panic("Qi TX does not have etxGasTip") } | ||
func (tx *QiTx) etxData() []byte { panic("Qi TX does not have etxData") } | ||
func (tx *QiTx) etxAccessList() AccessList { panic("Qi TX does not have etxAccessList") } | ||
func (tx *QiTx) originatingTxHash() common.Hash { | ||
panic("Qi TX does not have originatingTxHash") | ||
} | ||
func (tx *QiTx) etxIndex() uint16 { panic("Qi TX does not have etxIndex") } | ||
func (tx *QiTx) etxSender() common.Address { | ||
panic("Qi TX does not have etxSender") | ||
} | ||
func (tx *QiTx) txIn() []*TxIn { return tx.TxIn } | ||
func (tx *QiTx) txOut() []*TxOut { return tx.TxOut } | ||
|
||
func (tx *QiTx) getEcdsaSignatureValues() (v, r, s *big.Int) { | ||
panic("Qi TX does not have ECDSA signature values") | ||
} | ||
|
||
func (tx *QiTx) setEcdsaSignatureValues(chainID, v, r, s *big.Int) { | ||
panic("Qi TX does not have ECDSA signature values") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package types | ||
|
||
// SpentTxOut contains a spent transaction output and potentially additional | ||
// contextual information such as whether or not it was contained in a coinbase | ||
// transaction, the version of the transaction it was contained in, and which | ||
// block height the containing transaction was included in. As described in | ||
// the comments above, the additional contextual information will only be valid | ||
// when this spent txout is spending the last unspent output of the containing | ||
// transaction. | ||
type SpentTxOut struct { | ||
// Amount is the amount of the output. | ||
Amount uint64 | ||
|
||
// Address is the output holder's address. | ||
Address []byte | ||
|
||
// Height is the height of the block containing the creating tx. | ||
Height uint64 | ||
|
||
// Denotes if the creating tx is a coinbase. | ||
IsCoinBase bool | ||
} | ||
|
||
// countSpentOutputs returns the number of utxos the passed block spends. | ||
func CountSpentOutputs(block *Block) int { | ||
// Exclude the coinbase transaction since it can't spend anything. | ||
var numSpent int | ||
for _, tx := range block.QiTransactions()[1:] { | ||
numSpent += len(tx.TxIn()) | ||
} | ||
|
||
return numSpent | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.