From b8e0e98c655df27a0ff9ed827c4b49ce4670a9fc Mon Sep 17 00:00:00 2001 From: billettc Date: Wed, 11 Nov 2020 08:39:35 -0500 Subject: [PATCH] added decode func to OrderBook --- serum/types.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/serum/types.go b/serum/types.go index 44a94a4..2b8a060 100644 --- a/serum/types.go +++ b/serum/types.go @@ -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