Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master repair #153

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<img align="right" width="425px" src="https://github.com/xssnick/props/blob/master/logoimg.png?raw=true">

[![Based on TON][ton-svg]][ton]
![Coverage](https://img.shields.io/badge/Coverage-73.3%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-73.4%25-brightgreen)

Golang library for interacting with TON blockchain.

Expand Down
2 changes: 1 addition & 1 deletion adnl/rldp/http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func getDNSResolver() *dns.Client {
}

// initialize ton api lite connection wrapper
api := ton.NewAPIClient(client)
api := ton.NewAPIClient(client).WithRetry()

// get root dns address from network config
root, err := dns.RootContractAddr(api)
Expand Down
5 changes: 5 additions & 0 deletions liteclient/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ func (c *ConnectionPool) queryWithBalancer(req *ADNLRequest) (string, error) {
return "", ErrNoActiveConnections
}

if reqNode == nil {
// no active nodes in list
return "", ErrNoActiveConnections
}

host, err := reqNode.queryAdnl(req.QueryID, req.Data)
if err != nil {
if !errors.Is(err, NetworkErr{}) {
Expand Down
4 changes: 4 additions & 0 deletions tvm/cell/cell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ func TestBOCBomb(t *testing.T) {
if !bytes.Equal(c.Hash(), hash) {
t.Fatal("incorrect hash", hex.EncodeToString(c.Hash()), hex.EncodeToString(hash))
}

if len(c.ToBOCWithFlags(false)) != len(boc) {
t.Fatal("len", len(c.ToBOC()), len(boc))
}
}

func TestCell_TxWithMerkleBody(t *testing.T) {
Expand Down
31 changes: 28 additions & 3 deletions tvm/cell/flattenIndex.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ func flattenIndex(cells []*Cell) ([]*idxItem, map[string]*idxItem) {
for len(cells) > 0 {
next := make([]*Cell, 0, len(cells)*4)
for _, p := range cells {
hash := string(p.Hash())

if _, ok := index[hash]; ok {
continue
}

// move cell forward in boc, because behind reference is not allowed
index[string(p.Hash())] = &idxItem{
index: idx,
index[hash] = &idxItem{
cell: p,
index: idx,
}
idx++

next = append(next, p.refs...)
}
cells = next
Expand All @@ -33,6 +38,26 @@ func flattenIndex(cells []*Cell) ([]*idxItem, map[string]*idxItem) {
idxSlice = append(idxSlice, id)
}

for verifyOrder := true; verifyOrder; {
verifyOrder = false

for _, id := range idxSlice {
for _, ref := range id.cell.refs {
idRef := index[string(ref.Hash())]

if idRef.index < id.index {
// if we found that ref index is behind parent,
// move ref index forward
idRef.index = idx
idx++

// we changed index, so we need to verify order again
verifyOrder = true
}
}
}
}

sort.Slice(idxSlice, func(i, j int) bool {
return idxSlice[i].index < idxSlice[j].index
})
Expand Down
Loading