Introduce CommitOnly variant of Inputs (#3419)
* Introduce CommitOnly variant of Inputs. Introduce CommitWrapper so we can sort commit only inputs correctly. * rememebr to resort if converting * write inputs based on variant and protocol version * read and write protocol version specific inputs * store full blocks in local db in v3 convert to v2 when relaying to v2 peers * add debug version_str for inputs * no assumptions about spent index sort order * add additional version debug logs * fix ser/deser tests for proto v3 * cleanup coinbase maturity * rework pool to better handle v2 conversion robustly * cleanup txpool add_to_pool * fix nrd kernel test * move init conversion earlier * cleanup * cleanup based on PR feedback
This commit is contained in:
+15
-5
@@ -73,7 +73,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_DB_VERSION: ProtocolVersion = ProtocolVersion(2);
|
||||
const DEFAULT_DB_VERSION: ProtocolVersion = ProtocolVersion(3);
|
||||
|
||||
/// LMDB-backed store facilitating data access and serialization. All writes
|
||||
/// are done through a Batch abstraction providing atomicity.
|
||||
@@ -157,11 +157,16 @@ impl Store {
|
||||
env: self.env.clone(),
|
||||
db: self.db.clone(),
|
||||
name: self.name.clone(),
|
||||
version: version,
|
||||
version,
|
||||
alloc_chunk_size,
|
||||
}
|
||||
}
|
||||
|
||||
/// Protocol version for the store.
|
||||
pub fn protocol_version(&self) -> ProtocolVersion {
|
||||
self.version
|
||||
}
|
||||
|
||||
/// Opens the database environment
|
||||
pub fn open(&self) -> Result<(), Error> {
|
||||
let mut w = self.db.write();
|
||||
@@ -275,7 +280,7 @@ impl Store {
|
||||
) -> Result<Option<T>, Error> {
|
||||
let res: lmdb::error::Result<&[u8]> = access.get(&db, key);
|
||||
match res.to_opt() {
|
||||
Ok(Some(mut res)) => match ser::deserialize(&mut res, self.version) {
|
||||
Ok(Some(mut res)) => match ser::deserialize(&mut res, self.protocol_version()) {
|
||||
Ok(res) => Ok(Some(res)),
|
||||
Err(e) => Err(Error::SerErr(format!("{}", e))),
|
||||
},
|
||||
@@ -310,7 +315,7 @@ impl Store {
|
||||
cursor,
|
||||
seek: false,
|
||||
prefix: from.to_vec(),
|
||||
version: self.version,
|
||||
version: self.protocol_version(),
|
||||
_marker: marker::PhantomData,
|
||||
})
|
||||
}
|
||||
@@ -348,7 +353,12 @@ impl<'a> Batch<'a> {
|
||||
/// Writes a single key and its `Writeable` value to the db.
|
||||
/// Encapsulates serialization using the (default) version configured on the store instance.
|
||||
pub fn put_ser<W: ser::Writeable>(&self, key: &[u8], value: &W) -> Result<(), Error> {
|
||||
self.put_ser_with_version(key, value, self.store.version)
|
||||
self.put_ser_with_version(key, value, self.store.protocol_version())
|
||||
}
|
||||
|
||||
/// Protocol version used by this batch.
|
||||
pub fn protocol_version(&self) -> ProtocolVersion {
|
||||
self.store.protocol_version()
|
||||
}
|
||||
|
||||
/// Writes a single key and its `Writeable` value to the db.
|
||||
|
||||
Reference in New Issue
Block a user