fix error msg: composite literal uses unkeyed fields

pull/61/head
Minh Doan 6 years ago
parent b46bdaff40
commit 10c9acc8f6
  1. 2
      blockchain/blockchain.go
  2. 10
      client/txgen/main.go

@ -3,6 +3,7 @@ package blockchain
import ( import (
"bytes" "bytes"
"encoding/hex" "encoding/hex"
"github.com/dedis/kyber" "github.com/dedis/kyber"
"github.com/simple-rules/harmony-benchmark/crypto/pki" "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 // CreateBlockchain creates a new blockchain DB
// TODO(minhdoan): This func is not used, consider to remove.
func CreateBlockchain(address [20]byte, shardId uint32) *Blockchain { func CreateBlockchain(address [20]byte, shardId uint32) *Blockchain {
// TODO: We assume we have not created any blockchain before. // 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. // In current bitcoin, we can check if we created a blockchain before accessing local db.

@ -164,12 +164,16 @@ func generateCrossShardTx(txInfo *TxInfo) {
} }
// Spend the utxo from the current shard to a random address in [0 - N) // 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} txOutputs := []blockchain.TXOutput{txout}
// Spend the utxo from the other shard, if any, to a random address in [0 - N) // Spend the utxo from the other shard, if any, to a random address in [0 - N)
if crossTxin != nil { 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) txOutputs = append(txOutputs, crossTxout)
} }
@ -202,7 +206,7 @@ func generateSingleShardTx(txInfo *TxInfo) {
txin := blockchain.NewTXInput(blockchain.NewOutPoint(&txInfo.id, txInfo.index), txInfo.address, nodeShardID) txin := blockchain.NewTXInput(blockchain.NewOutPoint(&txInfo.id, txInfo.index), txInfo.address, nodeShardID)
// Spend the utxo to a random address in [0 - N) // 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} tx := blockchain.Transaction{ID: [32]byte{}, TxInput: []blockchain.TXInput{*txin}, TxOutput: []blockchain.TXOutput{txout}, Proofs: nil}
priKeyInt, ok := client.LookUpIntPriKey(txInfo.address) priKeyInt, ok := client.LookUpIntPriKey(txInfo.address)

Loading…
Cancel
Save