From dc0e8a6e233d975f66fcab89f02fea00e33e268f Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Wed, 31 Oct 2018 11:18:27 -0700 Subject: [PATCH] fix comments --- blockchain/utxopool.go | 3 ++- client/btctxiter/btctxiter.go | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/blockchain/utxopool.go b/blockchain/utxopool.go index 3d4a05d31..6e36e738e 100644 --- a/blockchain/utxopool.go +++ b/blockchain/utxopool.go @@ -119,7 +119,8 @@ func (utxoPool *UTXOPool) VerifyStateBlock(stateBlock *Block) bool { // Add another sanity check function (e.g. spending the same utxo) called before this one. func (utxoPool *UTXOPool) VerifyOneTransaction(tx *Transaction, spentTXOs *map[[20]byte]map[string]map[uint32]bool) (err error, crossShard bool) { var nilPubKey [32]byte - if tx.PublicKey == nilPubKey { // TODO(ricl): remove. just for btc replay. + // TODO(ricl): remove. just for btc replay. + if tx.PublicKey == nilPubKey { return nil, false } if len(tx.Proofs) > 1 { diff --git a/client/btctxiter/btctxiter.go b/client/btctxiter/btctxiter.go index bf1ceada4..ca298d429 100644 --- a/client/btctxiter/btctxiter.go +++ b/client/btctxiter/btctxiter.go @@ -14,6 +14,7 @@ import ( "github.com/btcsuite/btcutil" ) +// BTCTXIterator is a btc transaction iterator. type BTCTXIterator struct { blockIndex int64 block *btcjson.GetBlockVerboseResult @@ -22,6 +23,7 @@ type BTCTXIterator struct { client *rpcclient.Client } +// Init is an init function of BTCTXIterator. func (iter *BTCTXIterator) Init() { btcdHomeDir := btcutil.AppDataDir("btcd", false) certs, err := ioutil.ReadFile(filepath.Join(btcdHomeDir, "rpc.cert")) @@ -45,7 +47,7 @@ func (iter *BTCTXIterator) Init() { // defer iter.client.Shutdown() } -// Move to the next transaction +// NextTx is to move to the next transaction. func (iter *BTCTXIterator) NextTx() *btcjson.TxRawResult { iter.txIndex++ if iter.txIndex >= len(iter.block.RawTx) { @@ -57,22 +59,22 @@ func (iter *BTCTXIterator) NextTx() *btcjson.TxRawResult { return iter.tx } -// Gets the index/height of the current block +// GetBlockIndex gets the index/height of the current block func (iter *BTCTXIterator) GetBlockIndex() int64 { return iter.blockIndex } -// Gets the current block +// GetBlock gets the current block func (iter *BTCTXIterator) GetBlock() *btcjson.GetBlockVerboseResult { return iter.block } -// Gets the index of the current transaction +// GetTxIndex gets the index of the current transaction func (iter *BTCTXIterator) GetTxIndex() int { return iter.txIndex } -// Gets the current transaction +// GetTx gets the current transaction func (iter *BTCTXIterator) GetTx() *btcjson.TxRawResult { return iter.tx } @@ -98,6 +100,7 @@ func (iter *BTCTXIterator) nextBlock() *btcjson.GetBlockVerboseResult { return iter.block } +// IsCoinBaseTx returns true if tx is a coinbase tx. func IsCoinBaseTx(tx *btcjson.TxRawResult) bool { // A coin base must only have one transaction input. if len(tx.Vin) != 1 {