Skip to content

Commit

Permalink
Merge 7747e98 into e229d61
Browse files Browse the repository at this point in the history
  • Loading branch information
xssnick authored May 16, 2023
2 parents e229d61 + 7747e98 commit 82d1a9d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tlb/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,17 @@ func (m *InternalMessage) ToCell() (*cell.Cell, error) {
return nil, err
}

b.MustStoreBoolBit(true)
b.MustStoreRef(stateCell)
if int(b.BitsLeft())-2 < int(stateCell.BitsSize()) || int(b.RefsLeft())-1 < int(m.Body.RefsNum()) {
b.MustStoreBoolBit(true)
b.MustStoreRef(stateCell)
} else {
b.MustStoreBoolBit(false)
b.MustStoreBuilder(stateCell.ToBuilder())
}
}

if m.Body != nil {
if int(b.BitsLeft())-1 < int(m.Body.BitsSize()) {
if int(b.BitsLeft())-1 < int(m.Body.BitsSize()) || b.RefsLeft() < m.Body.RefsNum() {
b.MustStoreBoolBit(true)
b.MustStoreRef(m.Body)
} else {
Expand Down Expand Up @@ -242,7 +247,7 @@ func (m *ExternalMessage) ToCell() (*cell.Cell, error) {
return nil, fmt.Errorf("failed to serialize state init: %w", err)
}

if int(builder.BitsLeft())-2 < int(stateCell.BitsSize()) || int(builder.RefsLeft())-2 < int(m.Body.RefsNum()) {
if int(builder.BitsLeft())-2 < int(stateCell.BitsSize()) || int(builder.RefsLeft())-1 < int(m.Body.RefsNum()) {
builder.MustStoreBoolBit(true) // state as ref
builder.MustStoreRef(stateCell)
} else {
Expand Down

0 comments on commit 82d1a9d

Please sign in to comment.