File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -509,6 +509,7 @@ func handleGetValueByKeyHash(c *gin.Context) {
509509 // Convert value hash to hex for JSON response
510510 response := map [string ]interface {}{
511511 "valueHash" : hex .EncodeToString (result .ValueHash ),
512+ "proof" : result .Proof ,
512513 "timestamp" : result .Timestamp .Format (time .RFC3339Nano ),
513514 "slot" : result .Slot ,
514515 }
Original file line number Diff line number Diff line change @@ -913,6 +913,7 @@ type ValueHashWithTimestamp struct {
913913 ValueHash []byte `json:"valueHash"`
914914 Timestamp time.Time `json:"timestamp"`
915915 Slot int64 `json:"slot"`
916+ Proof string `json:"proof"`
916917}
917918
918919// GetValueByKey returns the current value for a specific object ID and raw key,
@@ -1032,9 +1033,26 @@ func (d *Database) GetValueHashByKeyHash(
10321033 return nil , nil
10331034 }
10341035
1036+ proof , err := d .ProveTrie (keyHash )
1037+ if err != nil {
1038+ return nil , fmt .Errorf (
1039+ "failed to prove trie for key hash %x: %w" ,
1040+ keyHash , err ,
1041+ )
1042+ }
1043+
1044+ proofBytes , err := proof .MarshalCBOR ()
1045+ if err != nil {
1046+ return nil , fmt .Errorf (
1047+ "failed to marshal proof for key hash %x: %w" ,
1048+ keyHash , err ,
1049+ )
1050+ }
1051+
10351052 return & ValueHashWithTimestamp {
10361053 ValueHash : result .ValueHash ,
10371054 Timestamp : result .DataTimestamp .UTC (),
10381055 Slot : result .DataSlot ,
1056+ Proof : hex .EncodeToString (proofBytes ),
10391057 }, nil
10401058}
You can’t perform that action at this time.
0 commit comments