-
Notifications
You must be signed in to change notification settings - Fork 338
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
api: add postage batch id header #886
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- i do not see any tests
- the post package should be removed, see pr postage: new pkg for postage stamps, uploader stamping #890
- batch id should be inherited through the context, not added to every method
pkg/post/stamper.go
Outdated
@@ -0,0 +1,12 @@ | |||
package post |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is not needed and should be removed
context attached values are optional by definition. if i understand correctly, batch id is not optional. correct me if i'm wrong |
I don't see what to test here (I kid you not). Let's add tests to this package once the stamper is wired into the pipeline, this way we can mock it and assert it was called with the correct value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR needs tests for at least that the http header is handled as expected, like we have for other headers.
pkg/api/api.go
Outdated
@@ -47,8 +49,15 @@ const ( | |||
var ( | |||
errInvalidNameOrAddress = errors.New("invalid name or bzz address") | |||
errNoResolver = errors.New("no resolver connected") | |||
errInvalidPostageBatch = errors.New("invalid postage batch id") | |||
|
|||
fallbackPostageBatch []byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a mutable shared variable between multiple goroutines and we cannot be sure that it will not be mutated, as it is passed to other components. I assume that it is an optimization to avoid allocations, but, I think that this optimization is not needed, and it is better to be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing my comments. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do not understand fallback to all zeros batch id otherwise ok
pkg/api/api.go
Outdated
if len(h) != 64 { | ||
return nil, errInvalidPostageBatch | ||
} | ||
return hex.DecodeString(h) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If value in the header is not hexadecimal it will return some internal error. This might have been handled, and returned errInvalidPostageBatch
again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense 👍 thanks
7d2ab49
to
926989f
Compare
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com> Storage incentives: add stamper putter to api Postage BatchStore and BatchService (#1070) Co-authored-by: zelig <viktor.tron@gmail.com> add normalisedBalance to updater interface (#1108) make value the normalised balance (#1111) postage: add event listener (#1099) Wire up postage stamp syncing (#1114) localstore, shed: persist stamps (#1116) add --postage to beeinfra.sh setup pullsync, pushsync: add postage stamps (#1117) postage: add create endpoint (#1142) retrieve erc20 address from postage contract (#1169) postage: check balance before attempting stamp creation (#1177) postage: fix bucket depth (#1178) api: use hex encoding in postage api (#1179) increase page size (#1182) postage: handle bucket depth error in api (#1183) localstore: attach stamp to outgoing chunk (#1192) update postage stamp contract addresses for new token (#1208) batchstore: reserve (#1262) * postage/batchstore: reserve logic Co-authored-by: acud <12988138+acud@users.noreply.github.com> stamp support in storage and protocols (#1321) api: endpoints for stamp issuers (#1535) retrieval: add stamps (#1552) localstore reserve logic (#1322) Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com> Storage incentives: add stamper putter to api Postage BatchStore and BatchService (#1070) Co-authored-by: zelig <viktor.tron@gmail.com> add normalisedBalance to updater interface (#1108) make value the normalised balance (#1111) postage: add event listener (#1099) Wire up postage stamp syncing (#1114) localstore, shed: persist stamps (#1116) add --postage to beeinfra.sh setup pullsync, pushsync: add postage stamps (#1117) postage: add create endpoint (#1142) retrieve erc20 address from postage contract (#1169) postage: check balance before attempting stamp creation (#1177) postage: fix bucket depth (#1178) api: use hex encoding in postage api (#1179) increase page size (#1182) postage: handle bucket depth error in api (#1183) localstore: attach stamp to outgoing chunk (#1192) update postage stamp contract addresses for new token (#1208) batchstore: reserve (#1262) * postage/batchstore: reserve logic Co-authored-by: acud <12988138+acud@users.noreply.github.com> stamp support in storage and protocols (#1321) api: endpoints for stamp issuers (#1535) retrieval: add stamps (#1552) localstore reserve logic (#1322) Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com> Storage incentives: add stamper putter to api Postage BatchStore and BatchService (#1070) Co-authored-by: zelig <viktor.tron@gmail.com> add normalisedBalance to updater interface (#1108) make value the normalised balance (#1111) postage: add event listener (#1099) Wire up postage stamp syncing (#1114) localstore, shed: persist stamps (#1116) add --postage to beeinfra.sh setup pullsync, pushsync: add postage stamps (#1117) postage: add create endpoint (#1142) retrieve erc20 address from postage contract (#1169) postage: check balance before attempting stamp creation (#1177) postage: fix bucket depth (#1178) api: use hex encoding in postage api (#1179) increase page size (#1182) postage: handle bucket depth error in api (#1183) localstore: attach stamp to outgoing chunk (#1192) update postage stamp contract addresses for new token (#1208) batchstore: reserve (#1262) * postage/batchstore: reserve logic Co-authored-by: acud <12988138+acud@users.noreply.github.com> stamp support in storage and protocols (#1321) api: endpoints for stamp issuers (#1535) retrieval: add stamps (#1552) localstore reserve logic (#1322) Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com> Storage incentives: add stamper putter to api Postage BatchStore and BatchService (#1070) Co-authored-by: zelig <viktor.tron@gmail.com> add normalisedBalance to updater interface (#1108) make value the normalised balance (#1111) postage: add event listener (#1099) Wire up postage stamp syncing (#1114) localstore, shed: persist stamps (#1116) add --postage to beeinfra.sh setup pullsync, pushsync: add postage stamps (#1117) postage: add create endpoint (#1142) retrieve erc20 address from postage contract (#1169) postage: check balance before attempting stamp creation (#1177) postage: fix bucket depth (#1178) api: use hex encoding in postage api (#1179) increase page size (#1182) postage: handle bucket depth error in api (#1183) localstore: attach stamp to outgoing chunk (#1192) update postage stamp contract addresses for new token (#1208) batchstore: reserve (#1262) * postage/batchstore: reserve logic Co-authored-by: acud <12988138+acud@users.noreply.github.com> stamp support in storage and protocols (#1321) api: endpoints for stamp issuers (#1535) retrieval: add stamps (#1552) localstore reserve logic (#1322) Co-authored-by: acud <12988138+acud@users.noreply.github.com>
postage: new pkg for postage stamps, uploader stamping (#890) * postage: new pkg for postage stamps, uploader stamping * postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch * postage: fix godoc and copyright * postage, swarm: - swarm.Stamp as an interface - add postage/testing for mock Stamps - fix Stamp MarshalBinary to allow nil batch id and signature - add StampSize const * postage: heed review feedback Co-authored-by: acud <12988138+acud@users.noreply.github.com> Storage incentives: add stamper putter to api Postage BatchStore and BatchService (#1070) Co-authored-by: zelig <viktor.tron@gmail.com> add normalisedBalance to updater interface (#1108) make value the normalised balance (#1111) postage: add event listener (#1099) Wire up postage stamp syncing (#1114) localstore, shed: persist stamps (#1116) add --postage to beeinfra.sh setup pullsync, pushsync: add postage stamps (#1117) postage: add create endpoint (#1142) retrieve erc20 address from postage contract (#1169) postage: check balance before attempting stamp creation (#1177) postage: fix bucket depth (#1178) api: use hex encoding in postage api (#1179) increase page size (#1182) postage: handle bucket depth error in api (#1183) localstore: attach stamp to outgoing chunk (#1192) update postage stamp contract addresses for new token (#1208) batchstore: reserve (#1262) * postage/batchstore: reserve logic Co-authored-by: acud <12988138+acud@users.noreply.github.com> stamp support in storage and protocols (#1321) api: endpoints for stamp issuers (#1535) retrieval: add stamps (#1552) localstore reserve logic (#1322) Co-authored-by: acud <12988138+acud@users.noreply.github.com>
Adds a postage batch ID header to the API
related to #872