-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed IStorage.cs to not depend on mondo types (#215)
- Loading branch information
1 parent
e27a2c9
commit 86e523f
Showing
11 changed files
with
103 additions
and
68 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
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,9 @@ | ||
using System.Collections.Generic; | ||
using Blockcore.Indexer.Core.Storage.Mongo.Types; | ||
|
||
namespace Blockcore.Indexer.Core.Storage.Mongo; | ||
|
||
public interface IMondoDbInfo | ||
{ | ||
public List<IndexView> GetIndexesBuildProgress(); | ||
} |
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,63 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Blockcore.Indexer.Core.Storage.Mongo.Types; | ||
using MongoDB.Bson; | ||
using MongoDB.Driver; | ||
|
||
namespace Blockcore.Indexer.Core.Storage.Mongo; | ||
|
||
public class MondoDbInfo : IMondoDbInfo | ||
{ | ||
private readonly IMongoDatabase mongoDatabase; | ||
|
||
public MondoDbInfo(IMongoDatabase mongoDatabase) | ||
{ | ||
this.mongoDatabase = mongoDatabase; | ||
} | ||
|
||
public List<IndexView> GetIndexesBuildProgress() | ||
{ | ||
IMongoDatabase db = mongoDatabase.Client.GetDatabase("admin"); | ||
var command = new BsonDocument { | ||
{ "currentOp", "1"}, | ||
}; | ||
BsonDocument currentOp = db.RunCommand<BsonDocument>(command); | ||
|
||
BsonElement inproc = currentOp.GetElement(0); | ||
var arr = inproc.Value as BsonArray; | ||
|
||
var ret = new List<IndexView>(); | ||
|
||
foreach (BsonValue bsonValue in arr) | ||
{ | ||
BsonElement? desc = bsonValue.AsBsonDocument?.GetElement("desc"); | ||
if (desc != null) | ||
{ | ||
bool track = desc?.Value.AsString.Contains("IndexBuildsCoordinatorMongod") ?? false; | ||
|
||
if (track) | ||
{ | ||
var indexed = new IndexView {Msg = bsonValue.AsBsonDocument?.GetElement("msg").Value.ToString()}; | ||
|
||
BsonElement? commandElement = bsonValue.AsBsonDocument?.GetElement("command"); | ||
|
||
string dbName = string.Empty; | ||
if (commandElement.HasValue) | ||
{ | ||
BsonDocument bsn = commandElement.Value.Value.AsBsonDocument; | ||
dbName = bsn.GetElement("$db").Value.ToString(); | ||
indexed.Command = $"{bsn.GetElement(0).Value}-{bsn.GetElement(1).Value}"; | ||
} | ||
|
||
if (dbName == mongoDatabase.DatabaseNamespace.DatabaseName) | ||
{ | ||
ret.Add(indexed); | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
return ret; | ||
} | ||
} |
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
File renamed without changes.
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
2 changes: 0 additions & 2 deletions
2
src/Blockcore.Indexer.Core/Storage/Mongo/Types/TransactionBlockTable.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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using System; | ||
|
||
namespace Blockcore.Indexer.Core.Storage.Mongo.Types | ||
{ | ||
public class TransactionBlockTable | ||
|
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,14 @@ | ||
namespace Blockcore.Indexer.Core.Storage.Types; | ||
|
||
public class Input | ||
{ | ||
public Outpoint Outpoint { get; set; } | ||
|
||
public string Address { get; set; } | ||
|
||
public long Value { get; set; } | ||
|
||
public string TrxHash { get; set; } | ||
|
||
public uint BlockIndex { get; set; } | ||
} |