mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
caf9bdbc6f
* commit initial work * checkpoint current work * gaz * checkpoint * req/resp changes * initial-sync * finally works * fix error * fix bugs * fix issue * fix issues * fix refs * tests * more text fixes * more text fixes * more text fixes * fix tests * fix tests * tests * finally fix builds * finally * comments * fix fuzz * share common library * fix * fix * add in more defensive nil checks * add in more defensive nil checks * imports * Apply suggestions from code review Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Apply suggestions from code review Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Update shared/interfaces/block_interface.go Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Update shared/interfaces/block_wrapper.go Co-authored-by: terence tsao <terence@prysmaticlabs.com> * Update shared/interfaces/block_interface.go Co-authored-by: terence tsao <terence@prysmaticlabs.com> * imports * fix bad changes * fix * terence's review * terence's review * fmt * Update beacon-chain/rpc/beacon/blocks.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * fix tests * fix * fix all tests Co-authored-by: terence tsao <terence@prysmaticlabs.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
122 lines
3.3 KiB
Go
122 lines
3.3 KiB
Go
package stategen
|
|
|
|
import (
|
|
"context"
|
|
|
|
types "github.com/prysmaticlabs/eth2-types"
|
|
iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface"
|
|
ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/interfaces"
|
|
)
|
|
|
|
// MockStateManager is a fake implementation of StateManager.
|
|
type MockStateManager struct {
|
|
StatesByRoot map[[32]byte]iface.BeaconState
|
|
StatesBySlot map[types.Slot]iface.BeaconState
|
|
}
|
|
|
|
// NewMockService --
|
|
func NewMockService() *MockStateManager {
|
|
return &MockStateManager{
|
|
StatesByRoot: make(map[[32]byte]iface.BeaconState),
|
|
StatesBySlot: make(map[types.Slot]iface.BeaconState),
|
|
}
|
|
}
|
|
|
|
// Resume --
|
|
func (m *MockStateManager) Resume(ctx context.Context) (iface.BeaconState, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
// SaveFinalizedState --
|
|
func (m *MockStateManager) SaveFinalizedState(fSlot types.Slot, fRoot [32]byte, fState iface.BeaconState) {
|
|
panic("implement me")
|
|
}
|
|
|
|
// MigrateToCold --
|
|
func (m *MockStateManager) MigrateToCold(ctx context.Context, fRoot [32]byte) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
// ReplayBlocks --
|
|
func (m *MockStateManager) ReplayBlocks(
|
|
ctx context.Context,
|
|
state iface.BeaconState,
|
|
signed []interfaces.SignedBeaconBlock,
|
|
targetSlot types.Slot,
|
|
) (iface.BeaconState, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
// LoadBlocks --
|
|
func (m *MockStateManager) LoadBlocks(
|
|
ctx context.Context,
|
|
startSlot, endSlot types.Slot,
|
|
endBlockRoot [32]byte,
|
|
) ([]interfaces.SignedBeaconBlock, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
// HasState --
|
|
func (m *MockStateManager) HasState(ctx context.Context, blockRoot [32]byte) (bool, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
// HasStateInCache --
|
|
func (m *MockStateManager) HasStateInCache(ctx context.Context, blockRoot [32]byte) (bool, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
// StateByRoot --
|
|
func (m *MockStateManager) StateByRoot(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error) {
|
|
return m.StatesByRoot[blockRoot], nil
|
|
}
|
|
|
|
// StateByRootInitialSync --
|
|
func (m *MockStateManager) StateByRootInitialSync(ctx context.Context, blockRoot [32]byte) (iface.BeaconState, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
// StateBySlot --
|
|
func (m *MockStateManager) StateBySlot(ctx context.Context, slot types.Slot) (iface.BeaconState, error) {
|
|
return m.StatesBySlot[slot], nil
|
|
}
|
|
|
|
// RecoverStateSummary --
|
|
func (m *MockStateManager) RecoverStateSummary(
|
|
ctx context.Context,
|
|
blockRoot [32]byte,
|
|
) (*ethereum_beacon_p2p_v1.StateSummary, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
// SaveState --
|
|
func (m *MockStateManager) SaveState(ctx context.Context, root [32]byte, st iface.BeaconState) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
// ForceCheckpoint --
|
|
func (m *MockStateManager) ForceCheckpoint(ctx context.Context, root []byte) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
// EnableSaveHotStateToDB --
|
|
func (m *MockStateManager) EnableSaveHotStateToDB(_ context.Context) {
|
|
panic("implement me")
|
|
}
|
|
|
|
// DisableSaveHotStateToDB --
|
|
func (m *MockStateManager) DisableSaveHotStateToDB(ctx context.Context) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
// AddStateForRoot --
|
|
func (m *MockStateManager) AddStateForRoot(state iface.BeaconState, blockRoot [32]byte) {
|
|
m.StatesByRoot[blockRoot] = state
|
|
}
|
|
|
|
// AddStateForSlot --
|
|
func (m *MockStateManager) AddStateForSlot(state iface.BeaconState, slot types.Slot) {
|
|
m.StatesBySlot[slot] = state
|
|
}
|