windows: handle large mapsizes gracefully

Update nostrdb to gracefully handle mapsizes that
are too large and fail to create nostrdb files.

We now keep shrinking the mapsize until database creation
succeeds. We still use the default mapsize of 32GiB on
windows, which is a bit annoying until we have nostrdb
resizing like monero.

Fixes: https://github.com/damus-io/notedeck/issues/491
This commit is contained in:
William Casarin
2024-11-28 16:40:18 -08:00
parent dea2873d9a
commit 8d59260935
4 changed files with 74 additions and 76 deletions

View File

@@ -17,25 +17,6 @@ pub enum Error {
Generic(String),
}
impl std::cmp::PartialEq for Error {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Error::Empty, Error::Empty) => true,
(Error::DecodeFailed, Error::DecodeFailed) => true,
(Error::HexDecodeFailed, Error::HexDecodeFailed) => true,
(Error::InvalidSignature, Error::InvalidSignature) => true,
(Error::InvalidByteSize, Error::InvalidByteSize) => true,
(Error::InvalidPublicKey, Error::InvalidPublicKey) => true,
// This is slightly wrong but whatevs
(Error::Json(..), Error::Json(..)) => true,
(Error::Generic(left), Error::Generic(right)) => left == right,
(Error::Nostrdb(left), Error::Nostrdb(right)) => left == right,
//(Error::Secp(left), Error::Secp(right)) => left == right,
_ => false,
}
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
@@ -54,8 +35,6 @@ impl fmt::Display for Error {
}
}
impl std::cmp::Eq for Error {}
impl From<String> for Error {
fn from(s: String) -> Self {
Error::Generic(s)