diff --git a/blockchain/block.go b/blockchain/block.go index 2e5f1fee6..536c4f57b 100644 --- a/blockchain/block.go +++ b/blockchain/block.go @@ -77,8 +77,8 @@ func (b *Block) String() string { func (b *Block) generateMerkleRootData() { var data [][]byte - for _, txId := range b.TransactionIds { - data = append(data, txId[:]) + for _, txID := range b.TransactionIds { + data = append(data, txID[:]) } merkleTre := NewMerkleTree(data) b.MerkleRootData = merkleTre.RootNode.Data @@ -115,12 +115,12 @@ func (b *Block) CalculateBlockHash() []byte { // NewBlock creates and returns a new block. func NewBlock(transactions []*Transaction, prevBlockHash [32]byte, shardID uint32) *Block { numTxs := int32(len(transactions)) - var txIds [][32]byte + var txIDs [][32]byte for _, tx := range transactions { - txIds = append(txIds, tx.ID) + txIDs = append(txIDs, tx.ID) } - block := &Block{Timestamp: time.Now().Unix(), PrevBlockHash: prevBlockHash, NumTransactions: numTxs, TransactionIds: txIds, Transactions: transactions, ShardID: shardID, Hash: [32]byte{}} + block := &Block{Timestamp: time.Now().Unix(), PrevBlockHash: prevBlockHash, NumTransactions: numTxs, TransactionIds: txIDs, Transactions: transactions, ShardID: shardID, Hash: [32]byte{}} copy(block.Hash[:], block.CalculateBlockHash()[:]) return block diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 1da0d7f10..54de7a168 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -124,8 +124,8 @@ func (bc *Blockchain) FindSpendableOutputs(address [20]byte, amount int) (int, m accumulated := 0 Work: - for txId, txOutputs := range unspentUtxos { - txID := hex.EncodeToString(txId[:]) + for txID, txOutputs := range unspentUtxos { + txID := hex.EncodeToString(txID[:]) for outIdx, txOutput := range txOutputs { if txOutput.Address == address && accumulated < amount { diff --git a/blockchain/utxopool.go b/blockchain/utxopool.go index 9693c66e5..66d0525be 100644 --- a/blockchain/utxopool.go +++ b/blockchain/utxopool.go @@ -29,11 +29,11 @@ type UTXOPool struct { /* The 3-d map's structure: address - [ - txId1 - [ + txID1 - [ outputIndex1 - value1 outputIndex2 - value2 ] - txId2 - [ + txID2 - [ outputIndex1 - value1 outputIndex2 - value2 ] @@ -554,8 +554,8 @@ func (utxoPool *UTXOPool) CountNumOfLockedUtxos() int { func countNumOfUtxos(utxos *UtxoMap) int { countAll := 0 for _, utxoMap := range *utxos { - for txIdStr, val := range utxoMap { - _, err := hex.DecodeString(txIdStr) + for txIDStr, val := range utxoMap { + _, err := hex.DecodeString(txIDStr) if err != nil { continue } diff --git a/client/txgen/main.go b/client/txgen/main.go index 8b53e8963..cdf180b72 100644 --- a/client/txgen/main.go +++ b/client/txgen/main.go @@ -79,11 +79,11 @@ func generateSimulatedTransactions(subsetId, numSubset int, shardID int, dataNod /* UTXO map structure: address - [ - txId1 - [ + txID1 - [ outputIndex1 - value1 outputIndex2 - value2 ] - txId2 - [ + txID2 - [ outputIndex1 - value1 outputIndex2 - value2 ] @@ -100,16 +100,16 @@ UTXOLOOP: for address, txMap := range dataNodes[shardID].UtxoPool.UtxoMap { if int(binary.BigEndian.Uint32(address[:]))%numSubset == subsetId%numSubset { // Work on one subset of utxo at a time txInfo.address = address - // Loop over all txIds for the address - for txIdStr, utxoMap := range txMap { + // Loop over all txIDs for the address + for txIDStr, utxoMap := range txMap { // Parse TxId - id, err := hex.DecodeString(txIdStr) + id, err := hex.DecodeString(txIDStr) if err != nil { continue } copy(txInfo.id[:], id[:]) - // Loop over all utxos for the txId + // Loop over all utxos for the txID utxoSize := len(utxoMap) batchSize := utxoSize / numSubset i := subsetId % numSubset diff --git a/client/wallet/main.go b/client/wallet/main.go index dbb573ed2..70a3b994a 100644 --- a/client/wallet/main.go +++ b/client/wallet/main.go @@ -174,15 +174,15 @@ func main() { txInputs := []blockchain.TXInput{} LOOP: for shardID, utxoMap := range shardUtxoMap { - for txId, vout2AmountMap := range utxoMap[senderAddressBytes] { - txIdBytes, err := utils.Get32BytesFromString(txId) + for txID, vout2AmountMap := range utxoMap[senderAddressBytes] { + txIDBytes, err := utils.Get32BytesFromString(txID) if err != nil { - fmt.Println("Failed to parse txId") + fmt.Println("Failed to parse txID") continue } for voutIndex, utxoAmount := range vout2AmountMap { cummulativeBalance += utxoAmount - txIn := blockchain.NewTXInput(blockchain.NewOutPoint(&txIdBytes, voutIndex), senderAddressBytes, shardID) + txIn := blockchain.NewTXInput(blockchain.NewOutPoint(&txIDBytes, voutIndex), senderAddressBytes, shardID) txInputs = append(txInputs, *txIn) if cummulativeBalance >= amount { break LOOP diff --git a/node/node_handler.go b/node/node_handler.go index 254fb971d..1b75a2963 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -244,7 +244,7 @@ func (node *Node) transactionMessageHandler(msgPayload []byte) { node.addPendingTransactions(*txList) case proto_node.REQUEST: reader := bytes.NewBuffer(msgPayload[1:]) - var txIds map[[32]byte]bool + var txIDs map[[32]byte]bool buf := make([]byte, 32) // 32 byte hash Id for { _, err := reader.Read(buf) @@ -252,14 +252,14 @@ func (node *Node) transactionMessageHandler(msgPayload []byte) { break } - var txId [32]byte - copy(txId[:], buf) - txIds[txId] = true + var txID [32]byte + copy(txID[:], buf) + txIDs[txID] = true } var txToReturn []*blockchain.Transaction for _, tx := range node.pendingTransactions { - if txIds[tx.ID] { + if txIDs[tx.ID] { txToReturn = append(txToReturn, tx) } } diff --git a/proto/node/node.go b/proto/node/node.go index bcc4a0963..4e8f29f60 100644 --- a/proto/node/node.go +++ b/proto/node/node.go @@ -155,8 +155,8 @@ func ConstructRequestTransactionsMessage(transactionIds [][]byte) []byte { byteBuffer := bytes.NewBuffer([]byte{byte(proto.NODE)}) byteBuffer.WriteByte(byte(TRANSACTION)) byteBuffer.WriteByte(byte(REQUEST)) - for _, txId := range transactionIds { - byteBuffer.Write(txId) + for _, txID := range transactionIds { + byteBuffer.Write(txID) } return byteBuffer.Bytes() }