Skip to content

Commit

Permalink
Fix wallet (#2291)
Browse files Browse the repository at this point in the history
- correctly return error
- update roster in 'cl' when getting new block
  • Loading branch information
ineiti authored May 26, 2020
1 parent 2dcf950 commit 6582446
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions byzcoin/wallet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func transfer(c *cli.Context) error {
if err := cfg.save(); err != nil {
return fmt.Errorf("couldn't save new roster: %v", err)
}
cl.Roster = cfg.BCConfig.Roster
}
if amount > balance {
return xerrors.New("your account doesn't have enough coins in it")
Expand All @@ -231,18 +232,18 @@ func transfer(c *cli.Context) error {
log.Warn("Only allowing 200 transactions at a time")
multi = 200
}
if multi > 0 {
if multi > 1 {
// For correct ordering of multiple transactions,
// it is important that all transactions are sent to the same node.
// Else they could be out-of-order and thus not match the correct
// counters.
node := rand.New(rand.NewSource(time.Now().UnixNano())).
Intn(len(cfg.BCConfig.Roster.List))
if err := cl.UseNode(node); err != nil {
return fmt.Errorf("couldn't set fixed node")
return fmt.Errorf("couldn't set fixed node: %v", err)
}
log.Info("Sending all transactions to node",
cfg.BCConfig.Roster.List[node], node)
cfg.BCConfig.Roster.List[node])
}
for tx := 0; tx < multi; tx++ {
counters.Counters[0]++
Expand Down

0 comments on commit 6582446

Please sign in to comment.