aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-11-30 00:47:47 +0800
committerchriseth <c@ethdev.com>2016-12-01 23:03:59 +0800
commit6a7ff039df15be59fbb71dc3dfaad09fb0b8961f (patch)
tree01d433c964f51111800766c30f230dd4c0e680ea /libsolidity/interface
parente0d4a3d518dc742d94571ef1e16b3f95765ec62f (diff)
downloaddexon-solidity-6a7ff039df15be59fbb71dc3dfaad09fb0b8961f.tar.gz
dexon-solidity-6a7ff039df15be59fbb71dc3dfaad09fb0b8961f.tar.zst
dexon-solidity-6a7ff039df15be59fbb71dc3dfaad09fb0b8961f.zip
Use CBOR encoding.
Diffstat (limited to 'libsolidity/interface')
-rw-r--r--libsolidity/interface/CompilerStack.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 357b18bd..d79345f0 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -611,7 +611,14 @@ void CompilerStack::compileContract(
shared_ptr<Compiler> compiler = make_shared<Compiler>(m_optimize, m_optimizeRuns);
Contract& compiledContract = m_contracts.at(_contract.name());
string onChainMetadata = createOnChainMetadata(compiledContract);
- compiler->compileContract(_contract, _compiledContracts, dev::swarmHash(onChainMetadata));
+ bytes cborEncodedMetadata =
+ // CBOR-encoding of {"bzzr0": dev::swarmHash(onChainMetadata)}
+ bytes{0xa1, 0x65, 'b', 'z', 'z', 'r', '0', 0x58, 0x20} +
+ dev::swarmHash(onChainMetadata).asBytes();
+ solAssert(cborEncodedMetadata.size() <= 0xffff, "Metadata too large");
+ // 16-bit big endian length
+ cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2);
+ compiler->compileContract(_contract, _compiledContracts, cborEncodedMetadata);
compiledContract.compiler = compiler;
compiledContract.object = compiler->assembledObject();
compiledContract.runtimeObject = compiler->runtimeObject();