Unverified Commit 95a7ed42 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #104 from rvagg/rvagg/filecoin-codecs

feat: add Filecoin multicodecs
parents a25d68f3 8dd6fe27
...@@ -58,75 +58,81 @@ const ( ...@@ -58,75 +58,81 @@ const (
GitRaw = 0x78 GitRaw = 0x78
EthBlock = 0x90 EthBlock = 0x90
EthBlockList = 0x91 EthBlockList = 0x91
EthTxTrie = 0x92 EthTxTrie = 0x92
EthTx = 0x93 EthTx = 0x93
EthTxReceiptTrie = 0x94 EthTxReceiptTrie = 0x94
EthTxReceipt = 0x95 EthTxReceipt = 0x95
EthStateTrie = 0x96 EthStateTrie = 0x96
EthAccountSnapshot = 0x97 EthAccountSnapshot = 0x97
EthStorageTrie = 0x98 EthStorageTrie = 0x98
BitcoinBlock = 0xb0 BitcoinBlock = 0xb0
BitcoinTx = 0xb1 BitcoinTx = 0xb1
ZcashBlock = 0xc0 ZcashBlock = 0xc0
ZcashTx = 0xc1 ZcashTx = 0xc1
DecredBlock = 0xe0 DecredBlock = 0xe0
DecredTx = 0xe1 DecredTx = 0xe1
DashBlock = 0xf0 DashBlock = 0xf0
DashTx = 0xf1 DashTx = 0xf1
FilCommitmentUnsealed = 0xf101
FilCommitmentSealed = 0xf102
) )
// Codecs maps the name of a codec to its type // Codecs maps the name of a codec to its type
var Codecs = map[string]uint64{ var Codecs = map[string]uint64{
"v0": DagProtobuf, "v0": DagProtobuf,
"raw": Raw, "raw": Raw,
"protobuf": DagProtobuf, "protobuf": DagProtobuf,
"cbor": DagCBOR, "cbor": DagCBOR,
"libp2p-key": Libp2pKey, "libp2p-key": Libp2pKey,
"git-raw": GitRaw, "git-raw": GitRaw,
"eth-block": EthBlock, "eth-block": EthBlock,
"eth-block-list": EthBlockList, "eth-block-list": EthBlockList,
"eth-tx-trie": EthTxTrie, "eth-tx-trie": EthTxTrie,
"eth-tx": EthTx, "eth-tx": EthTx,
"eth-tx-receipt-trie": EthTxReceiptTrie, "eth-tx-receipt-trie": EthTxReceiptTrie,
"eth-tx-receipt": EthTxReceipt, "eth-tx-receipt": EthTxReceipt,
"eth-state-trie": EthStateTrie, "eth-state-trie": EthStateTrie,
"eth-account-snapshot": EthAccountSnapshot, "eth-account-snapshot": EthAccountSnapshot,
"eth-storage-trie": EthStorageTrie, "eth-storage-trie": EthStorageTrie,
"bitcoin-block": BitcoinBlock, "bitcoin-block": BitcoinBlock,
"bitcoin-tx": BitcoinTx, "bitcoin-tx": BitcoinTx,
"zcash-block": ZcashBlock, "zcash-block": ZcashBlock,
"zcash-tx": ZcashTx, "zcash-tx": ZcashTx,
"decred-block": DecredBlock, "decred-block": DecredBlock,
"decred-tx": DecredTx, "decred-tx": DecredTx,
"dash-block": DashBlock, "dash-block": DashBlock,
"dash-tx": DashTx, "dash-tx": DashTx,
"fil-commitment-unsealed": FilCommitmentUnsealed,
"fil-commitment-sealed": FilCommitmentSealed,
} }
// CodecToStr maps the numeric codec to its name // CodecToStr maps the numeric codec to its name
var CodecToStr = map[uint64]string{ var CodecToStr = map[uint64]string{
Raw: "raw", Raw: "raw",
DagProtobuf: "protobuf", DagProtobuf: "protobuf",
DagCBOR: "cbor", DagCBOR: "cbor",
GitRaw: "git-raw", GitRaw: "git-raw",
EthBlock: "eth-block", EthBlock: "eth-block",
EthBlockList: "eth-block-list", EthBlockList: "eth-block-list",
EthTxTrie: "eth-tx-trie", EthTxTrie: "eth-tx-trie",
EthTx: "eth-tx", EthTx: "eth-tx",
EthTxReceiptTrie: "eth-tx-receipt-trie", EthTxReceiptTrie: "eth-tx-receipt-trie",
EthTxReceipt: "eth-tx-receipt", EthTxReceipt: "eth-tx-receipt",
EthStateTrie: "eth-state-trie", EthStateTrie: "eth-state-trie",
EthAccountSnapshot: "eth-account-snapshot", EthAccountSnapshot: "eth-account-snapshot",
EthStorageTrie: "eth-storage-trie", EthStorageTrie: "eth-storage-trie",
BitcoinBlock: "bitcoin-block", BitcoinBlock: "bitcoin-block",
BitcoinTx: "bitcoin-tx", BitcoinTx: "bitcoin-tx",
ZcashBlock: "zcash-block", ZcashBlock: "zcash-block",
ZcashTx: "zcash-tx", ZcashTx: "zcash-tx",
DecredBlock: "decred-block", DecredBlock: "decred-block",
DecredTx: "decred-tx", DecredTx: "decred-tx",
DashBlock: "dash-block", DashBlock: "dash-block",
DashTx: "dash-tx", DashTx: "dash-tx",
FilCommitmentUnsealed: "fil-commitment-unsealed",
FilCommitmentSealed: "fil-commitment-sealed",
} }
// tryNewCidV0 tries to convert a multihash into a CIDv0 CID and returns an // tryNewCidV0 tries to convert a multihash into a CIDv0 CID and returns an
......
...@@ -16,28 +16,30 @@ import ( ...@@ -16,28 +16,30 @@ import (
// https://github.com/multiformats/go-multihash/blob/7aa9f26a231c6f34f4e9fad52bf580fd36627285/multihash_test.go#L13 // https://github.com/multiformats/go-multihash/blob/7aa9f26a231c6f34f4e9fad52bf580fd36627285/multihash_test.go#L13
// Makes it so changing the table accidentally has to happen twice. // Makes it so changing the table accidentally has to happen twice.
var tCodecs = map[uint64]string{ var tCodecs = map[uint64]string{
Raw: "raw", Raw: "raw",
DagProtobuf: "protobuf", DagProtobuf: "protobuf",
DagCBOR: "cbor", DagCBOR: "cbor",
Libp2pKey: "libp2p-key", Libp2pKey: "libp2p-key",
GitRaw: "git-raw", GitRaw: "git-raw",
EthBlock: "eth-block", EthBlock: "eth-block",
EthBlockList: "eth-block-list", EthBlockList: "eth-block-list",
EthTxTrie: "eth-tx-trie", EthTxTrie: "eth-tx-trie",
EthTx: "eth-tx", EthTx: "eth-tx",
EthTxReceiptTrie: "eth-tx-receipt-trie", EthTxReceiptTrie: "eth-tx-receipt-trie",
EthTxReceipt: "eth-tx-receipt", EthTxReceipt: "eth-tx-receipt",
EthStateTrie: "eth-state-trie", EthStateTrie: "eth-state-trie",
EthAccountSnapshot: "eth-account-snapshot", EthAccountSnapshot: "eth-account-snapshot",
EthStorageTrie: "eth-storage-trie", EthStorageTrie: "eth-storage-trie",
BitcoinBlock: "bitcoin-block", BitcoinBlock: "bitcoin-block",
BitcoinTx: "bitcoin-tx", BitcoinTx: "bitcoin-tx",
ZcashBlock: "zcash-block", ZcashBlock: "zcash-block",
ZcashTx: "zcash-tx", ZcashTx: "zcash-tx",
DecredBlock: "decred-block", DecredBlock: "decred-block",
DecredTx: "decred-tx", DecredTx: "decred-tx",
DashBlock: "dash-block", DashBlock: "dash-block",
DashTx: "dash-tx", DashTx: "dash-tx",
FilCommitmentUnsealed: "fil-commitment-unsealed",
FilCommitmentSealed: "fil-commitment-sealed",
} }
func assertEqual(t *testing.T, a, b Cid) { func assertEqual(t *testing.T, a, b Cid) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment