added decode func to OrderBook

This commit is contained in:
billettc 2020-11-11 08:39:35 -05:00
parent adfd8f2142
commit b8e0e98c65
1 changed files with 8 additions and 0 deletions

View File

@ -101,6 +101,14 @@ type Orderbook struct {
Nodes []SlabNode `struc:""`
}
func (o *Orderbook) Decode(in []byte) error {
err := struc.Unpack(bytes.NewReader(in), o)
if err != nil {
return fmt.Errorf("order book: unpack: %w", err)
}
return nil
}
func (o *Orderbook) Items(descending bool, f func(node *SlabLeafNode) error) error {
if o.LeafCount == 0 {
return nil