-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement epoch APIs/dashboard page (#2560)
* Implement epoch webapis * Add Epoch livefeed on dashboard * Add Epoch Page * Refactor fetch and update states * Split locks between commitment and metadata * Align websocket message types * Align epoch jsonmodel naming to the protocol * Create a workerpool for commitment * Avoid global typesettings in commitment retainer * Remove cachedCommitment * Stream ouputs in retainer * Remove unused const * Expose Workers in retainer * Refactor OutputsProvider * Rename CommitmentByID to stick to camel case naming * Evict blockMetadata with workerpool * Process data fields in setCommitment * Remove unreachable codes * Minor fixes --------- Co-authored-by: jonastheis <[email protected]>
- Loading branch information
1 parent
afe8e07
commit ca3a151
Showing
30 changed files
with
849 additions
and
553 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package retainer | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/iotaledger/goshimmer/packages/core/commitment" | ||
"github.com/iotaledger/goshimmer/packages/protocol/engine/notarization" | ||
"github.com/iotaledger/goshimmer/packages/protocol/ledger" | ||
"github.com/iotaledger/goshimmer/packages/protocol/ledger/utxo" | ||
"github.com/iotaledger/goshimmer/packages/protocol/models" | ||
"github.com/iotaledger/hive.go/objectstorage/generic/model" | ||
"github.com/iotaledger/hive.go/serializer/v2/serix" | ||
) | ||
|
||
type CommitmentDetails struct { | ||
model.Storable[commitment.ID, CommitmentDetails, *CommitmentDetails, commitmentDetailsModel] `serix:"0"` | ||
} | ||
|
||
type commitmentDetailsModel struct { | ||
ID commitment.ID `serix:"0"` | ||
|
||
Commitment *commitment.Commitment `serix:"1"` | ||
AcceptedBlocks models.BlockIDs `serix:"2,lengthPrefixType=uint32"` | ||
AcceptedTransactions utxo.TransactionIDs `serix:"3,lengthPrefixType=uint32"` | ||
CreatedOutputs utxo.OutputIDs `serix:"4,lengthPrefixType=uint32"` | ||
SpentOutputs utxo.OutputIDs `serix:"5,lengthPrefixType=uint32"` | ||
} | ||
|
||
func newCommitmentDetails() (c *CommitmentDetails) { | ||
c = model.NewStorable[commitment.ID, CommitmentDetails](&commitmentDetailsModel{ | ||
AcceptedBlocks: make(models.BlockIDs), | ||
AcceptedTransactions: utxo.NewTransactionIDs(), | ||
SpentOutputs: utxo.NewOutputIDs(), | ||
CreatedOutputs: utxo.NewOutputIDs(), | ||
}) | ||
c.SetID(commitment.ID{}) | ||
|
||
return c | ||
} | ||
|
||
func (c *CommitmentDetails) setCommitment(e *notarization.EpochCommittedDetails) { | ||
c.M.Commitment = e.Commitment | ||
c.M.ID = e.Commitment.ID() | ||
c.SetID(e.Commitment.ID()) | ||
|
||
_ = e.AcceptedBlocks.Stream(func(key models.BlockID) bool { | ||
c.M.AcceptedBlocks.Add(key) | ||
return true | ||
}) | ||
_ = e.AcceptedTransactions.Stream(func(key utxo.TransactionID) bool { | ||
c.M.AcceptedTransactions.Add(key) | ||
return true | ||
}) | ||
|
||
_ = e.SpentOutputs(func(owm *ledger.OutputWithMetadata) error { | ||
c.M.SpentOutputs.Add(owm.ID()) | ||
return nil | ||
}) | ||
|
||
_ = e.CreatedOutputs(func(owm *ledger.OutputWithMetadata) error { | ||
c.M.CreatedOutputs.Add(owm.ID()) | ||
return nil | ||
}) | ||
} | ||
|
||
func (c *CommitmentDetails) Encode() ([]byte, error) { | ||
return serix.DefaultAPI.Encode(context.Background(), c.M) | ||
} | ||
|
||
func (c *CommitmentDetails) Decode(bytes []byte) (int, error) { | ||
return serix.DefaultAPI.Decode(context.Background(), bytes, &c.M) | ||
} | ||
|
||
func (c *CommitmentDetails) MarshalJSON() ([]byte, error) { | ||
return serix.DefaultAPI.JSONEncode(context.Background(), c.M) | ||
} | ||
|
||
func (c *CommitmentDetails) UnmarshalJSON(bytes []byte) error { | ||
return serix.DefaultAPI.JSONDecode(context.Background(), bytes, &c.M) | ||
} |
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.