diff --git a/pkg/api/stewardship.go b/pkg/api/stewardship.go index e617549d88f..135212e0224 100644 --- a/pkg/api/stewardship.go +++ b/pkg/api/stewardship.go @@ -29,7 +29,7 @@ func (s *Service) stewardshipPutHandler(w http.ResponseWriter, r *http.Request) } headers := struct { - BatchID []byte `map:"Swarm-Postage-Batch-Id"` + BatchID []byte `map:"Swarm-Postage-Batch-Id" validate:"required"` }{} if response := s.mapStructure(r.Header, &headers); response != nil { response("invalid header params", logger, w) @@ -41,18 +41,7 @@ func (s *Service) stewardshipPutHandler(w http.ResponseWriter, r *http.Request) err error ) - if len(headers.BatchID) == 0 { - logger.Debug("missing postage batch id for re-upload") - batchID, err = s.storer.BatchHint(paths.Address) - if err != nil { - logger.Debug("unable to find old batch for reference", "error", err) - logger.Error(nil, "unable to find old batch for reference") - jsonhttp.NotFound(w, "unable to find old batch for reference, provide new batch id") - return - } - } else { - batchID = headers.BatchID - } + batchID = headers.BatchID stamper, save, err := s.getStamper(batchID) if err != nil { switch { diff --git a/pkg/api/stewardship_test.go b/pkg/api/stewardship_test.go index 005b0bd66ad..da28708e999 100644 --- a/pkg/api/stewardship_test.go +++ b/pkg/api/stewardship_test.go @@ -40,6 +40,7 @@ func TestStewardship(t *testing.T) { Message: http.StatusText(http.StatusOK), Code: http.StatusOK, }), + jsonhttptest.WithRequestHeader("Swarm-Postage-Batch-Id", "aa"), ) if !stewardMock.LastAddress().Equal(addr) { t.Fatalf("\nhave address: %q\nwant address: %q", stewardMock.LastAddress().String(), addr.String()) diff --git a/pkg/node/node.go b/pkg/node/node.go index 11a918d4e1d..f4fd8423959 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -183,7 +183,7 @@ const ( minPaymentThreshold = 2 * refreshRate // minimal accepted payment threshold of full nodes maxPaymentThreshold = 24 * refreshRate // maximal accepted payment threshold of full nodes mainnetNetworkID = uint64(1) // - ReserveCapacity = 65536 // 2^14 chunks + ReserveCapacity = 131072 // 2^14 chunks reserveWakeUpDuration = 5 * time.Minute // time to wait before waking up reserveWorker reserveTreshold = ReserveCapacity * 5 / 10 reserveMinimumRadius = 0 diff --git a/pkg/storer/internal/transaction/mem.go b/pkg/storer/internal/transaction/mem.go index a8a71c4bb4e..6881e147461 100644 --- a/pkg/storer/internal/transaction/mem.go +++ b/pkg/storer/internal/transaction/mem.go @@ -1,3 +1,7 @@ +// Copyright 2024 The Swarm Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package transaction import ( diff --git a/pkg/storer/internal/transaction/mem_test.go b/pkg/storer/internal/transaction/mem_test.go index cf032a45bd0..254edbf6cb1 100644 --- a/pkg/storer/internal/transaction/mem_test.go +++ b/pkg/storer/internal/transaction/mem_test.go @@ -1,4 +1,4 @@ -// Copyright 2023 The Swarm Authors. All rights reserved. +// Copyright 2024 The Swarm Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/pkg/storer/internal/transaction/transaction.go b/pkg/storer/internal/transaction/transaction.go index e50ada4ee47..ffe73cef1da 100644 --- a/pkg/storer/internal/transaction/transaction.go +++ b/pkg/storer/internal/transaction/transaction.go @@ -5,7 +5,7 @@ /* Package transaction provides transaction support for localstore operations. All writes to the localstore (both indexstore and chunkstore) must be made using a transaction. -The transaction must be commited for the writes to be stored on the disk. +The transaction must be committed for the writes to be stored on the disk. Writes to the transaction are cached in memory so that future Reads return the cached entries, or if not available, entries stored on the disk. The rules of the transction is as follows: @@ -84,7 +84,7 @@ type transaction struct { // were returned from the storage ops or commit. Safest option is to do a defer call immediately after // creating the transaction. // Calls made to the transaction are NOT thread-safe. -// Write operations are stored in memory so that future Read operations return what is currently captured in the transaciton. +// Write operations are stored in memory so that future Read operations return what is currently captured in the transaction. // For example, calling chunkstore.Put twice and then chunkstore.Delete once will cause the chunk to be stored with a refCnt of 1. // This is important for certain operations like storing the same chunk multiple times in the same transaction with the // expectation that the refCnt in the chunkstore correctly responds to number of Put calls. @@ -134,7 +134,7 @@ func (s *store) ChunkStore() storage.ReadOnlyChunkStore { // Run creates a new transaction and gives the caller access to the transaction // in the form of a callback function. After the callback returns, the transaction -// is commited to the disk. See the Transaction method for more details on how transactions operate internally. +// is committed to the disk. See the Transaction method for more details on how transactions operate internally. func (s *store) Run(ctx context.Context, f func(Store) error) error { trx, done := s.NewTransaction(ctx) defer done() diff --git a/pkg/storer/storer.go b/pkg/storer/storer.go index 8c4d0a3ef38..64dfd2221f1 100644 --- a/pkg/storer/storer.go +++ b/pkg/storer/storer.go @@ -77,8 +77,6 @@ type UploadStore interface { DeleteSession(tagID uint64) error // ListSessions will list all the Sessions currently being tracked. ListSessions(offset, limit int) ([]SessionInfo, error) - // BatchHint will return the batch ID hint for the chunk reference if known. - BatchHint(swarm.Address) ([]byte, error) } // PinStore is a logical component of the storer which deals with pinning diff --git a/pkg/storer/uploadstore.go b/pkg/storer/uploadstore.go index 68c6f158127..96eed326fc8 100644 --- a/pkg/storer/uploadstore.go +++ b/pkg/storer/uploadstore.go @@ -162,8 +162,3 @@ func (db *DB) ListSessions(offset, limit int) ([]SessionInfo, error) { return tags[min(offset, len(tags)):min(offset+limit, len(tags))], nil } - -// BatchHint is the implementation of the UploadStore.BatchHint method. -func (db *DB) BatchHint(address swarm.Address) ([]byte, error) { - return upload.BatchIDForChunk(db.storage.IndexStore(), address) -}