MCPcopy Create free account
hub / github.com/ElementsProject/elements / Write

Method Write

src/dbwrapper.h:73–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72 template <typename K, typename V>
73 void Write(const K& key, const V& value)
74 {
75 ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
76 ssKey << key;
77 leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
78
79 ssValue.reserve(DBWRAPPER_PREALLOC_VALUE_SIZE);
80 ssValue << value;
81 ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent));
82 leveldb::Slice slValue((const char*)ssValue.data(), ssValue.size());
83
84 batch.Put(slKey, slValue);
85 // LevelDB serializes writes as:
86 // - byte: header
87 // - varint: key length (1 byte up to 127B, 2 bytes up to 16383B, ...)
88 // - byte[]: key
89 // - varint: value length
90 // - byte[]: value
91 // The formula below assumes the key and value are both less than 16k.
92 size_estimate += 3 + (slKey.size() > 127) + slKey.size() + (slValue.size() > 127) + slValue.size();
93 ssKey.clear();
94 ssValue.clear();
95 }
96
97 template <typename K>
98 void Erase(const K& key)

Callers 1

WriteMethod · 0.45

Calls 6

XorMethod · 0.80
reserveMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
PutMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected