@@ -38,16 +38,33 @@ public enum Codec {
3838 }
3939
4040 private static Map <Long , Codec > lookup = new TreeMap <>();
41+ private static Map <String , Codec > nameLookup = new TreeMap <>();
4142 static {
4243 for (Codec c : Codec .values ())
4344 lookup .put (c .type , c );
45+ // https://github.com/multiformats/multicodec/blob/master/table.csv
46+ nameLookup .put ("raw" , Raw );
47+ nameLookup .put ("dag-pb" , DagProtobuf );
48+ nameLookup .put ("dag-cbor" , DagCbor );
49+ nameLookup .put ("libp2p-key" , Libp2pKey );
50+ nameLookup .put ("eth-block" , EthereumBlock );
51+ nameLookup .put ("eth-block-list" , EthereumTx );
52+ nameLookup .put ("bitcoin-block" , BitcoinBlock );
53+ nameLookup .put ("bitcoin-tx" , BitcoinTx );
54+ nameLookup .put ("zcash-block" , ZcashBlock );
55+ nameLookup .put ("zcash-tx" , ZcashTx );
4456 }
4557
4658 public static Codec lookup (long c ) {
4759 if (!lookup .containsKey (c ))
4860 throw new IllegalStateException ("Unknown Codec type: " + c );
4961 return lookup .get (c );
5062 }
63+ public static Codec lookupIPLDName (String name ) {
64+ if (!nameLookup .containsKey (name ))
65+ throw new IllegalStateException ("Unknown Codec type: " + name );
66+ return nameLookup .get (name );
67+ }
5168 }
5269
5370 public final long version ;
0 commit comments