我完全迷失了。我必须创建一个公共分类帐,其当前的UTXOPool(未使用的事务输出集合)是{@code utxoPool}。这应该使用UTXOPool(UTXOPool uPool)构造函数制作utxoPool的副本。我的代码粘贴在下面..
public class TxHandler {
/**
* Creates a public ledger whose current UTXOPool (collection of unspent transaction outputs) is
* {@code utxoPool}. This should make a copy of utxoPool by using the UTXOPool(UTXOPool uPool)
* constructor.
*/
public TxHandler(UTXOPool utxoPool) {
// IMPLEMENT THIS
this.
}
/**
* @return true if:
* (1) all outputs claimed by {@code tx} are in the current UTXO pool,
* (2) the signatures on each input of {@code tx} are valid,
* (3) no UTXO is claimed multiple times by {@code tx},
* (4) all of {@code tx}s output values are non-negative, and
* (5) the sum of {@code tx}s input values is greater than or equal to the sum of its output
* values; and false otherwise.
*/
public boolean isValidTx(Transaction tx) {
// IMPLEMENT THIS
}
/**
* Handles each epoch by receiving an unordered array of proposed transactions, checking each
* transaction for correctness, returning a mutually valid array of accepted transactions, and
* updating the current UTXO pool as appropriate.
*/
public Transaction[] handleTxs(Transaction[] possibleTxs) {
// IMPLEMENT THIS
}
}
答案 0 :(得分:0)
如果另一个类放在另一个包中,则需要确保初始类和要调用的方法都是公共的,然后在另一个类中需要导入初始类:< / p>
import your.original.package.TxHandler;
然后调用它的方法。
答案 1 :(得分:0)
从指令 - “这应该使用UTXOPool(UTXOPool uPool)构造函数制作utxoPool的副本。”
所以你的构造函数应该是这样的
public TxHandler(UTXOPool utxoPool) {
// IMPLEMENT THIS
this.utxoPool = new UTXOPool(utxoPool)
}