Skip to content

Commit

Permalink
update ADR to reflect implementation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-forbes committed Mar 10, 2021
1 parent 5b9ebda commit 3b52870
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
11 changes: 1 addition & 10 deletions docs/lazy-adr/adr-002-ipds-da-sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func RetrieveBlockData(ctx contex.Context, dah *DataAvailabilityHeader) (types.D
// the row to the Merkle Dag, in our case a Namespaced Merkle Tree.
// Note, that this method could also fill the DA header.
// The data will be pinned by default.
func (b *Block) PutBlock(ctx contex.Context) error
func (b *Block) PutBlock(ctx contex.Context, nodeAdder ipld.NodeAdder) error
```

We now describe the lower-level library that will be used by above methods.
Expand All @@ -185,15 +185,6 @@ func GetLeafData(
leafIndex uint32,
totalLeafs uint32, // this corresponds to the extended square width
) ([]byte, error)

// PutLeaves takes the namespaced leaves, a row of the from the extended data square,
// and calls nodes.DataSquareRowOrColumnRawInputParser of the ipld plugin.
// The resulting ipld nodes are passed to a Batch calling AddMany:
// https://github.com/ipfs/go-ipld-format/blob/d2e09424ddee0d7e696d01143318d32d0fb1ae63/batch.go#L29
// Note, that this method could also return the row and column roots.
// Tha caller is responsible for making sure that the leaves are sorted by namespace ID.
// The data will be pinned by default.
func PutLeaves(ctx contex.Context, namespacedLeaves [][]byte) error
```

`GetLeafData` can be used by above `ValidateAvailability` and `RetrieveBlock` and
Expand Down
6 changes: 3 additions & 3 deletions types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ func mustPush(rowTree *nmt.NamespacedMerkleTree, id namespace.ID, data []byte) {

// PutBlock posts and pins erasured block data to IPFS using the provided
// ipld.NodeAdder. Note: the erasured data is currently recomputed
func (b *Block) PutBlock(ctx context.Context, api format.NodeAdder) error {
if api == nil {
func (b *Block) PutBlock(ctx context.Context, nodeAdder format.NodeAdder) error {
if nodeAdder == nil {
return errors.New("no ipfs node adder provided")
}

Expand All @@ -292,7 +292,7 @@ func (b *Block) PutBlock(ctx context.Context, api format.NodeAdder) error {
// iterate through each set of col and row leaves
for _, leafSet := range leaves {
// create a batch per each leafSet
batchAdder := nodes.NewNmtNodeAdder(ctx, format.NewBatch(ctx, api))
batchAdder := nodes.NewNmtNodeAdder(ctx, format.NewBatch(ctx, nodeAdder))
tree := nmt.New(sha256.New(), nmt.NodeVisitor(batchAdder.Visit))
for _, share := range leafSet {
err = tree.Push(share[:NamespaceSize], share[NamespaceSize:])
Expand Down

0 comments on commit 3b52870

Please sign in to comment.