From 6f3b36e17bb2080f6cf74852da03b1b429748780 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 28 Oct 2020 22:27:18 -0400 Subject: [PATCH] fix index out of range error during bitbus sync --- bmap.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/bmap.go b/bmap.go index ef9240a..71f503c 100644 --- a/bmap.go +++ b/bmap.go @@ -36,17 +36,20 @@ func NewFromBob(bobTx *bob.Tx) (bmapTx *Tx, err error) { func (bTx *Tx) FromBob(bobTx *bob.Tx) (err error) { for _, out := range bobTx.Out { for _, tape := range out.Tape { - switch tape.Cell[0].S { - case aip.Prefix: - bTx.AIP = aip.NewFromTape(tape) - bTx.AIP.SetDataFromTape(out.Tape) - case bap.Prefix: - bTx.BAP, err = bap.NewFromTape(&tape) - case magic.Prefix: - bTx.MAP, err = magic.NewFromTape(&tape) - case b.Prefix: - bTx.B = b.New() - err = bTx.B.FromTape(tape) + if len(tape.Cell) > 0 { + prefixData := tape.Cell[0].S + switch prefixData { + case aip.Prefix: + bTx.AIP = aip.NewFromTape(tape) + bTx.AIP.SetDataFromTape(out.Tape) + case bap.Prefix: + bTx.BAP, err = bap.NewFromTape(&tape) + case magic.Prefix: + bTx.MAP, err = magic.NewFromTape(&tape) + case b.Prefix: + bTx.B = b.New() + err = bTx.B.FromTape(tape) + } } }