-
Notifications
You must be signed in to change notification settings - Fork 932
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
231 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package bitswap | ||
|
||
import ( | ||
"hash" | ||
|
||
blocks "github.com/ipfs/go-block-format" | ||
"github.com/ipfs/go-cid" | ||
mh "github.com/multiformats/go-multihash" | ||
|
||
"github.com/celestiaorg/rsmt2d" | ||
) | ||
|
||
// RegisterBlock registers the new Block type. | ||
func RegisterBlock(mhcode, codec uint64, size int, bldrFn func(cid.Cid) (blockBuilder, error)) { | ||
mh.Register(mhcode, func() hash.Hash { | ||
return &hasher{IDSize: size} | ||
}) | ||
specRegistry[mhcode] = idSpec{ | ||
size: size, | ||
codec: codec, | ||
builder: bldrFn, | ||
} | ||
} | ||
|
||
var specRegistry = make(map[uint64]idSpec) | ||
|
||
type idSpec struct { | ||
size int | ||
codec uint64 | ||
builder func(cid.Cid) (blockBuilder, error) | ||
} | ||
|
||
type blockBuilder interface { | ||
// BlockFromEDS gets Bitswap Block out of the EDS. | ||
BlockFromEDS(*rsmt2d.ExtendedDataSquare) (blocks.Block, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.