From 10c9acc8f6e33ba83636a879b654005ff67fd6fb Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Fri, 24 Aug 2018 11:58:26 -0700 Subject: [PATCH] fix error msg: composite literal uses unkeyed fields --- blockchain/blockchain.go | 2 ++ client/txgen/main.go | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 6a1a4408d..807a7d5a7 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -3,6 +3,7 @@ package blockchain import ( "bytes" "encoding/hex" + "github.com/dedis/kyber" "github.com/simple-rules/harmony-benchmark/crypto/pki" ) @@ -183,6 +184,7 @@ func (bc *Blockchain) VerifyNewBlockAndUpdate(utxopool *UTXOPool, block *Block) } // CreateBlockchain creates a new blockchain DB +// TODO(minhdoan): This func is not used, consider to remove. func CreateBlockchain(address [20]byte, shardId uint32) *Blockchain { // TODO: We assume we have not created any blockchain before. // In current bitcoin, we can check if we created a blockchain before accessing local db. diff --git a/client/txgen/main.go b/client/txgen/main.go index 719142c9c..18dc6b8b1 100644 --- a/client/txgen/main.go +++ b/client/txgen/main.go @@ -164,12 +164,16 @@ func generateCrossShardTx(txInfo *TxInfo) { } // Spend the utxo from the current shard to a random address in [0 - N) - txout := blockchain.TXOutput{txInfo.value, pki.GetAddressFromInt(rand.Intn(setting.numOfAddress) + 1), nodeShardID} + txout := blockchain.TXOutput{ + Amount: txInfo.value, + Address: pki.GetAddressFromInt(rand.Intn(setting.numOfAddress) + 1), + ShardID: nodeShardID} + txOutputs := []blockchain.TXOutput{txout} // Spend the utxo from the other shard, if any, to a random address in [0 - N) if crossTxin != nil { - crossTxout := blockchain.TXOutput{crossUtxoValue, pki.GetAddressFromInt(rand.Intn(setting.numOfAddress) + 1), uint32(crossShardId)} + crossTxout := blockchain.TXOutput{Amount: crossUtxoValue, Address: pki.GetAddressFromInt(rand.Intn(setting.numOfAddress) + 1), ShardID: uint32(crossShardId)} txOutputs = append(txOutputs, crossTxout) } @@ -202,7 +206,7 @@ func generateSingleShardTx(txInfo *TxInfo) { txin := blockchain.NewTXInput(blockchain.NewOutPoint(&txInfo.id, txInfo.index), txInfo.address, nodeShardID) // Spend the utxo to a random address in [0 - N) - txout := blockchain.TXOutput{txInfo.value, pki.GetAddressFromInt(rand.Intn(setting.numOfAddress) + 1), nodeShardID} + txout := blockchain.TXOutput{Amount: txInfo.value, Address: pki.GetAddressFromInt(rand.Intn(setting.numOfAddress) + 1), ShardID: nodeShardID} tx := blockchain.Transaction{ID: [32]byte{}, TxInput: []blockchain.TXInput{*txin}, TxOutput: []blockchain.TXOutput{txout}, Proofs: nil} priKeyInt, ok := client.LookUpIntPriKey(txInfo.address)