Skip to content

Commit

Permalink
Merge pull request ethereum#548 from thanhnguyennguyen/error-handling
Browse files Browse the repository at this point in the history
error-handling
  • Loading branch information
ngtuna authored Jun 27, 2019
2 parents 0edf37f + 5e3ea58 commit cb1af05
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tomox/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func prepareOrderTreeData(tree *OrderTree) (*OrderTreeSnapshot, error) {
snap := new(OrderTreeSnapshot)
serializedTree, err = EncodeBytesItem(tree.Item)
if err != nil {
return snap, err
return nil, err
}
snap.OrderTreeItem = serializedTree

Expand All @@ -104,7 +104,11 @@ func prepareOrderTreeData(tree *OrderTree) (*OrderTreeSnapshot, error) {
priceKeyHash := common.BytesToHash(key)
bytes, found := tree.PriceTree.Get(key)
if found {
ol := tree.decodeOrderList(bytes)
var ol *OrderList
ol, err = tree.decodeOrderList(bytes)
if err != nil {
return nil, err
}
// snapshot orderItems
var (
items [][]byte
Expand All @@ -113,11 +117,11 @@ func prepareOrderTreeData(tree *OrderTree) (*OrderTreeSnapshot, error) {
for ol != nil && ol.Item != nil && ol.Item.Length > 0 {
headOrder := ol.GetOrder(ol.Item.HeadOrder)
if byteItem, err = EncodeBytesItem(headOrder.Item); err != nil {
return snap, err
return nil, err
}
items = append(items, byteItem)
if err = ol.RemoveOrder(headOrder); err != nil {
return snap, err
return nil, err
}
}

Expand Down

0 comments on commit cb1af05

Please sign in to comment.