-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from Etherna/feature/BHM-149-import-beeturbo
Feature/bhm 149 import beeturbo
- Loading branch information
Showing
60 changed files
with
1,549 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ services: | |
networks: | ||
- mongo-net | ||
ports: | ||
- 80:80 | ||
- 1633:1633 | ||
restart: unless-stopped | ||
|
||
mongo: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2021-present Etherna SA | ||
// This file is part of Beehive. | ||
// | ||
// Beehive is free software: you can redistribute it and/or modify it under the terms of the | ||
// GNU Affero General Public License as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// Beehive is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License along with Beehive. | ||
// If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Etherna.BeeNet.Models; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Etherna.Beehive.Domain.Models | ||
{ | ||
public class Chunk : EntityModelBase<string> | ||
{ | ||
// Constructors. | ||
public Chunk(SwarmHash hash, byte[] payload) | ||
{ | ||
Hash = hash; | ||
Payload = payload; | ||
} | ||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
public Chunk() { } | ||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
|
||
// Properties. | ||
public virtual SwarmHash Hash { get; protected set; } | ||
|
||
[SuppressMessage("Performance", "CA1819:Properties should not return arrays")] | ||
public virtual byte[] Payload { get; protected set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2021-present Etherna SA | ||
// This file is part of Beehive. | ||
// | ||
// Beehive is free software: you can redistribute it and/or modify it under the terms of the | ||
// GNU Affero General Public License as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// Beehive is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License along with Beehive. | ||
// If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Etherna.BeeNet.Models; | ||
|
||
namespace Etherna.Beehive.Domain.Models | ||
{ | ||
public class UploadedChunkRef : EntityModelBase<string> | ||
{ | ||
// Constructors. | ||
public UploadedChunkRef(SwarmHash hash, PostageBatchId batchId) | ||
{ | ||
Hash = hash; | ||
BatchId = batchId; | ||
} | ||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
protected UploadedChunkRef() { } | ||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
|
||
// Properties. | ||
public virtual PostageBatchId BatchId { get; protected set; } | ||
public virtual SwarmHash Hash { get; protected set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2021-present Etherna SA | ||
// This file is part of Beehive. | ||
// | ||
// Beehive is free software: you can redistribute it and/or modify it under the terms of the | ||
// GNU Affero General Public License as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// Beehive is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License along with Beehive. | ||
// If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Etherna.Beehive.Persistence.Serializers; | ||
using Etherna.BeeNet.Models; | ||
using Etherna.MongODM.Core; | ||
using Etherna.MongODM.Core.Serialization; | ||
|
||
namespace Etherna.Beehive.Persistence.ModelMaps | ||
{ | ||
internal sealed class BeeNetMap : IModelMapsCollector | ||
{ | ||
public void Register(IDbContext dbContext) | ||
{ | ||
dbContext.MapRegistry.AddModelMap<PostageBatchId>( //v0.4.0 | ||
"57e606db-94be-4b3f-85fc-193483020012", | ||
customSerializer: new PostageBatchIdSerializer()); | ||
|
||
dbContext.MapRegistry.AddModelMap<SwarmAddress>( //v0.4.0 | ||
"5d4d4d6a-5448-43ca-aa74-50c6d0d82f25", | ||
customSerializer: new SwarmAddressSerializer()); | ||
|
||
dbContext.MapRegistry.AddModelMap<SwarmHash>( //v0.4.0 | ||
"64231e24-1cfc-4b24-8c7a-20f0f708969a", | ||
customSerializer: new SwarmHashSerializer()); | ||
|
||
dbContext.MapRegistry.AddModelMap<SwarmUri>( //v0.4.0 | ||
"99d8f98f-cfa4-4490-aeda-5dc2df7fdba8", | ||
customSerializer: new SwarmUriSerializer()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2021-present Etherna SA | ||
// This file is part of Beehive. | ||
// | ||
// Beehive is free software: you can redistribute it and/or modify it under the terms of the | ||
// GNU Affero General Public License as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// Beehive is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License along with Beehive. | ||
// If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Etherna.Beehive.Domain.Models; | ||
using Etherna.MongoDB.Bson.Serialization.Serializers; | ||
using Etherna.MongODM.Core; | ||
using Etherna.MongODM.Core.Serialization; | ||
|
||
namespace Etherna.Beehive.Persistence.ModelMaps | ||
{ | ||
internal sealed class ChunkMap : IModelMapsCollector | ||
{ | ||
public void Register(IDbContext dbContext) | ||
{ | ||
dbContext.MapRegistry.AddModelMap<Chunk>( //v0.4.0 | ||
"06aaf593-07af-4fca-99a9-bdc3718547d8", | ||
mm => | ||
{ | ||
mm.AutoMap(); | ||
mm.MapProperty(c => c.Payload).SetSerializer(ByteArraySerializer.Instance); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2021-present Etherna SA | ||
// This file is part of Beehive. | ||
// | ||
// Beehive is free software: you can redistribute it and/or modify it under the terms of the | ||
// GNU Affero General Public License as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// Beehive is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License along with Beehive. | ||
// If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Etherna.Beehive.Domain.Models; | ||
using Etherna.MongODM.Core; | ||
using Etherna.MongODM.Core.Serialization; | ||
|
||
namespace Etherna.Beehive.Persistence.ModelMaps | ||
{ | ||
internal sealed class UploadedChunkRefMap : IModelMapsCollector | ||
{ | ||
public void Register(IDbContext dbContext) | ||
{ | ||
dbContext.MapRegistry.AddModelMap<UploadedChunkRef>( | ||
"30e3473f-5d56-4821-9c66-aa8922b46942"); //v0.4.0 | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Beehive.Persistence/Serializers/PostageBatchIdSerializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2021-present Etherna SA | ||
// This file is part of Beehive. | ||
// | ||
// Beehive is free software: you can redistribute it and/or modify it under the terms of the | ||
// GNU Affero General Public License as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// Beehive is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License along with Beehive. | ||
// If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Etherna.BeeNet.Models; | ||
using Etherna.MongoDB.Bson.Serialization; | ||
using Etherna.MongoDB.Bson.Serialization.Serializers; | ||
|
||
namespace Etherna.Beehive.Persistence.Serializers | ||
{ | ||
public class PostageBatchIdSerializer : SerializerBase<PostageBatchId> | ||
{ | ||
private readonly StringSerializer stringSerializer = new(); | ||
|
||
public override PostageBatchId Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) | ||
{ | ||
var batchId = stringSerializer.Deserialize(context, args); | ||
return PostageBatchId.FromString(batchId); | ||
} | ||
|
||
public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, PostageBatchId value) | ||
{ | ||
stringSerializer.Serialize(context, args, value.ToString()); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Beehive.Persistence/Serializers/SwarmAddressSerializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2021-present Etherna SA | ||
// This file is part of Beehive. | ||
// | ||
// Beehive is free software: you can redistribute it and/or modify it under the terms of the | ||
// GNU Affero General Public License as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// Beehive is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License along with Beehive. | ||
// If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Etherna.BeeNet.Models; | ||
using Etherna.MongoDB.Bson.Serialization; | ||
using Etherna.MongoDB.Bson.Serialization.Serializers; | ||
|
||
namespace Etherna.Beehive.Persistence.Serializers | ||
{ | ||
public class SwarmAddressSerializer : SerializerBase<SwarmAddress> | ||
{ | ||
private readonly StringSerializer stringSerializer = new(); | ||
|
||
public override SwarmAddress Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) | ||
{ | ||
var address = stringSerializer.Deserialize(context, args); | ||
return SwarmAddress.FromString(address); | ||
} | ||
|
||
public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, SwarmAddress value) | ||
{ | ||
stringSerializer.Serialize(context, args, value.ToString()); | ||
} | ||
} | ||
} |
Oops, something went wrong.