Skip to content

Commit

Permalink
[WIP] P-Chain merkle DB -- smaller diff (#2382)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Laine authored Nov 29, 2023
1 parent 764c24f commit 1161e11
Show file tree
Hide file tree
Showing 8 changed files with 1,079 additions and 1,110 deletions.
7 changes: 5 additions & 2 deletions vms/platformvm/state/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,12 @@ func (d *diff) GetSubnetTransformation(subnetID ids.ID) (*txs.Tx, error) {
func (d *diff) AddSubnetTransformation(transformSubnetTxIntf *txs.Tx) {
transformSubnetTx := transformSubnetTxIntf.Unsigned.(*txs.TransformSubnetTx)
if d.transformedSubnets == nil {
d.transformedSubnets = make(map[ids.ID]*txs.Tx)
d.transformedSubnets = map[ids.ID]*txs.Tx{
transformSubnetTx.Subnet: transformSubnetTxIntf,
}
} else {
d.transformedSubnets[transformSubnetTx.Subnet] = transformSubnetTxIntf
}
d.transformedSubnets[transformSubnetTx.Subnet] = transformSubnetTxIntf
}

func (d *diff) GetChains(subnetID ids.ID) ([]*txs.Tx, error) {
Expand Down
10 changes: 3 additions & 7 deletions vms/platformvm/state/masked_iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,19 @@ func TestMaskedIterator(t *testing.T) {
stakers := []*Staker{
{
TxID: ids.GenerateTestID(),
Weight: 0, // just to simplify debugging
NextTime: time.Unix(0, 0),
},
{
TxID: ids.GenerateTestID(),
Weight: 10, // just to simplify debugging
NextTime: time.Unix(10, 0),
NextTime: time.Unix(1, 0),
},
{
TxID: ids.GenerateTestID(),
Weight: 20, // just to simplify debugging
NextTime: time.Unix(20, 0),
NextTime: time.Unix(2, 0),
},
{
TxID: ids.GenerateTestID(),
Weight: 30, // just to simplify debugging
NextTime: time.Unix(30, 0),
NextTime: time.Unix(3, 0),
},
}
maskedStakers := map[ids.ID]*Staker{
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/state/staker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestNewCurrentStaker(t *testing.T) {
subnetID := ids.GenerateTestID()
weight := uint64(12345)
startTime := time.Now()
endTime := startTime.Add(time.Hour)
endTime := time.Now()
potentialReward := uint64(54321)
currentPriority := txs.SubnetPermissionedValidatorCurrentPriority

Expand Down
Loading

0 comments on commit 1161e11

Please sign in to comment.