-
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.
Added an endpoint to get the logs based on range of block ids (#181)
* Added an endpoint to get the logs for list of blocks * Pagination Fix (#171) * Pagination Fix * Update CirrusMongoData.cs * Update CirrusMongoData.cs * Added a customer serializer for IDictionary<string,object> in case the object is a complex object * Fix for BSON to JSON conversion issue with long numbers * Removed unused services in controller * Added the missing block hash from the endpoint response * Added to block index count for the new index added * Added split of number of block index indexes count in the db in Cirrus and main code Co-authored-by: TheDude <[email protected]> Co-authored-by: YakupIpek <[email protected]>
- Loading branch information
1 parent
4835f90
commit 59b9560
Showing
12 changed files
with
173 additions
and
42 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
46 changes: 46 additions & 0 deletions
46
src/Blockcore.Indexer.Cirrus/Models/QueryBlockSmartContractsLogs.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,46 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Blockcore.Indexer.Cirrus.Models; | ||
|
||
public class QueryBlockSmartContractsLogs | ||
{ | ||
public string TransactionHash { get; set; } | ||
public string BlockHash { get; set; } | ||
public long BlockNumber { get; set; } | ||
public string PostState { get; set; } | ||
public ulong GasUsed { get; set; } | ||
public string From { get; set; } | ||
public string To { get; set; } | ||
public string NewContractAddress { get; set; } | ||
public bool Success { get; set; } | ||
public string ReturnValue { get; set; } | ||
public string Bloom { get; set; } | ||
public string Error { get; set; } | ||
|
||
// public string MethodName { get; set; } | ||
// public string ContractCodeType { get; set; } | ||
// public string ContractBytecode { get; set; } | ||
// public string ContractCodeHash { get; set; } | ||
// public string ContractCSharp { get; set; } | ||
// public ulong GasPrice { get; set; } | ||
// public ulong Amount { get; set; } | ||
// public ulong ContractBalance { get; set; } | ||
|
||
public LogResponse[] Logs { get; set; } | ||
|
||
public class LogResponse | ||
{ | ||
public string Address { get; set; } | ||
public string[] Topics { get; set; } | ||
public string Data { get; set; } | ||
|
||
public LogData Log { get; set; } | ||
} | ||
|
||
public class LogData | ||
{ | ||
public string Event { get; set; } | ||
|
||
public IDictionary<string, object> Data { get; 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
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
31 changes: 31 additions & 0 deletions
31
src/Blockcore.Indexer.Cirrus/Storage/Mongo/ComplexTypeSerializer.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,31 @@ | ||
using System.Collections.Generic; | ||
using MongoDB.Bson; | ||
using MongoDB.Bson.IO; | ||
using MongoDB.Bson.Serialization; | ||
using MongoDB.Bson.Serialization.Serializers; | ||
using JsonConvert = Newtonsoft.Json.JsonConvert; | ||
|
||
namespace Blockcore.Indexer.Cirrus.Storage.Mongo; | ||
|
||
public class ComplexTypeSerializer : SerializerBase<object> | ||
{ | ||
public override object Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) | ||
{ | ||
var serializer = BsonSerializer.LookupSerializer(typeof(BsonDocument)); | ||
var document = serializer.Deserialize(context, args); | ||
|
||
var bsonDocument = document.ToBsonDocument(); | ||
|
||
var result = BsonExtensionMethods.ToJson(bsonDocument,new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }); | ||
return JsonConvert.DeserializeObject<IDictionary<string, object>>(result); | ||
} | ||
|
||
public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, object value) | ||
{ | ||
var jsonDocument = JsonConvert.SerializeObject(value); | ||
var bsonDocument = BsonSerializer.Deserialize<BsonDocument>(jsonDocument); | ||
|
||
var serializer = BsonSerializer.LookupSerializer(typeof(BsonDocument)); | ||
serializer.Serialize(context, bsonDocument.AsBsonValue); | ||
} | ||
} |
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
Oops, something went wrong.