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

Stop using the pinning option as a default #276

Merged
merged 3 commits into from
Apr 9, 2021
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 consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ func (cs *State) defaultDecideProposal(height int64, round int32) {
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*1500)
defer cancel()
// TODO: post data to IPFS in a goroutine
err := block.PutBlock(ctx, cs.IpfsAPI.Dag().Pinning())
err := block.PutBlock(ctx, cs.IpfsAPI.Dag())
if err != nil {
cs.Logger.Error(fmt.Sprintf("failure to post block data to IPFS: %s", err.Error()))
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/ipld/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestGetLeafData(t *testing.T) {

// create the context and batch needed for node collection from the tree
ctx := context.Background()
batch := format.NewBatch(ctx, ipfsAPI.Dag().Pinning())
batch := format.NewBatch(ctx, ipfsAPI.Dag())

// generate random data for the nmt
data := generateRandNamespacedRawData(16, types.NamespaceSize, types.ShareSize)
Expand Down
17 changes: 5 additions & 12 deletions types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
gogotypes "github.com/gogo/protobuf/types"
coreapi "github.com/ipfs/go-ipfs/core/coreapi"
coremock "github.com/ipfs/go-ipfs/core/mock"
"github.com/ipfs/interface-go-ipfs-core/path"
"github.com/lazyledger/lazyledger-core/p2p/ipld/plugin/nodes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1340,6 +1339,9 @@ func TestPutBlock(t *testing.T) {
t.Error(err)
}

maxOriginalSquareSize := MaxSquareSize / 2
maxShareCount := maxOriginalSquareSize * maxOriginalSquareSize

testCases := []struct {
name string
blockData Data
Expand All @@ -1349,7 +1351,7 @@ func TestPutBlock(t *testing.T) {
{"no leaves", generateRandomMsgOnlyData(0), false, ""},
{"single leaf", generateRandomMsgOnlyData(1), false, ""},
{"16 leaves", generateRandomMsgOnlyData(16), false, ""},
{"max square size", generateRandomMsgOnlyData(MaxSquareSize), false, ""},
{"max square size", generateRandomMsgOnlyData(maxShareCount), false, ""},
}
ctx := context.Background()
for _, tc := range testCases {
Expand All @@ -1358,7 +1360,7 @@ func TestPutBlock(t *testing.T) {
block := &Block{Data: tc.blockData}

t.Run(tc.name, func(t *testing.T) {
err = block.PutBlock(ctx, ipfsAPI.Dag().Pinning())
err = block.PutBlock(ctx, ipfsAPI.Dag())
if tc.expectErr {
require.Error(t, err)
require.Contains(t, err.Error(), tc.errString)
Expand All @@ -1378,15 +1380,6 @@ func TestPutBlock(t *testing.T) {
t.Error(err)
}

// check if cid was successfully pinned to IPFS
_, pinned, err := ipfsAPI.Pin().IsPinned(ctx, path.IpldPath(cid))
if err != nil {
t.Error(err)
}
if !pinned {
t.Errorf("failure to pin cid %s to IPFS", cid.String())
}

// retrieve the data from IPFS
_, err = ipfsAPI.Dag().Get(timeoutCtx, cid)
if err != nil {
Expand Down