addressing RJs comments

pull/917/head
ak 5 years ago
parent 9f46a2ae44
commit 35ede709aa
  1. 4
      api/service/syncing/syncing.go
  2. 9
      cmd/client/txgen/main.go
  3. 2
      node/node_syncing.go

@ -608,8 +608,8 @@ func (ss *StateSync) getMaxPeerHeight() uint64 {
return maxHeight
}
// IsItSameBlockchainHeight checks whether the node is out of sync from other peers
func (ss *StateSync) IsItSameBlockchainHeight(bc *core.BlockChain) (uint64, bool) {
// IsSameBlockchainHeight checks whether the node is out of sync from other peers
func (ss *StateSync) IsSameBlockchainHeight(bc *core.BlockChain) (uint64, bool) {
otherHeight := ss.getMaxPeerHeight()
currentHeight := bc.CurrentBlock().NumberU64()
return otherHeight, currentHeight == otherHeight

@ -62,7 +62,7 @@ func printVersion(me string) {
var (
ip = flag.String("ip", "127.0.0.1", "IP of the node")
port = flag.String("port", "9999", "port of the node.")
numTxns = flag.Int("numTxns", 100, "number of transactions to send per message should be divisble by 100")
numTxns = flag.Int("numTxns", 100, "number of transactions to send per message")
logFolder = flag.String("log_folder", "latest", "the folder collecting the logs of this execution")
duration = flag.Int("duration", 30, "duration of the tx generation in second. If it's negative, the experiment runs forever.")
versionFlag = flag.Bool("version", false, "Output version info")
@ -270,6 +270,7 @@ func GenerateSimulatedTransactionsAccount(shardID uint32, node *node.Node, setti
TxnsToGenerate := setting.MaxNumTxsPerBatch // TODO: make use of settings
txs := make([]*types.Transaction, TxnsToGenerate)
rounds := (TxnsToGenerate / 100)
remainder := TxnsToGenerate % 100
for i := 0; i < 100; i++ {
baseNonce := node.Worker.GetCurrentState().GetNonce(crypto.PubkeyToAddress(node.TestBankKeys[i].PublicKey))
for j := 0; j < rounds; j++ {
@ -278,6 +279,12 @@ func GenerateSimulatedTransactionsAccount(shardID uint32, node *node.Node, setti
tx, _ := types.SignTx(types.NewTransaction(baseNonce+uint64(j), randomUserAddress, shardID, big.NewInt(int64(params.Ether*randAmount)), params.TxGas, nil, nil), types.HomesteadSigner{}, node.TestBankKeys[i])
txs[100*j+i] = tx
}
if i < remainder {
randomUserAddress := crypto.PubkeyToAddress(node.TestBankKeys[rand.Intn(100)].PublicKey)
randAmount := rand.Float32()
tx, _ := types.SignTx(types.NewTransaction(baseNonce+uint64(rounds), randomUserAddress, shardID, big.NewInt(int64(params.Ether*randAmount)), params.TxGas, nil, nil), types.HomesteadSigner{}, node.TestBankKeys[i])
txs[100*rounds+i] = tx
}
}
return txs, nil
}

@ -53,7 +53,7 @@ func (node *Node) IsSameHeight() (uint64, bool) {
if node.stateSync == nil {
node.stateSync = syncing.CreateStateSync(node.SelfPeer.IP, node.SelfPeer.Port, node.GetSyncID())
}
return node.stateSync.IsItSameBlockchainHeight(node.Blockchain())
return node.stateSync.IsSameBlockchainHeight(node.Blockchain())
}
// GetBeaconSyncingPeers returns a list of peers for beaconchain syncing

Loading…
Cancel
Save