fairdb

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PENDING stType = iota
	LEADER
	FOLLOWER
)
View Source
const DbName = "Anduschain"

Variables

View Source
var (
	MongDBConnectError = errors.New("fail to connecting mongo database")
	MongDBPingFail     = errors.New("ping failed")
)
View Source
var (
	ErrAlreadyExistBlock = errors.New("already exist block")
)

Functions

func IsDup added in v0.6.20

func IsDup(err error) bool

E11000 duplicate key error reference mgo.IsDup

func MakeVoteKey

func MakeVoteKey(otprn common.Hash, blockNum *big.Int) common.Hash

func RecvOtprn

func RecvOtprn(s *mongo.SingleResult) (*types.Otprn, error)

func TransBlock

func TransBlock(block *types.Block) fntype.Block

func TransOtprn

func TransOtprn(otprn types.Otprn) (fntype.Otprn, error)

func TransTransaction

func TransTransaction(block *types.Block, chainID *big.Int, txC *mongo.Collection)

Types

type FairnodeDB

type FairnodeDB interface {
	Start() error
	Stop()

	GetChainConfig() *types.ChainConfig
	SaveChainConfig(config *types.ChainConfig) error

	CurrentInfo() *types.CurrentInfo
	CurrentBlock() *types.Block
	CurrentOtprn() *types.Otprn

	InitActiveNode()
	SaveActiveNode(node types.HeartBeat)
	GetActiveNode() []types.HeartBeat
	RemoveActiveNode(enode string)

	SaveOtprn(otprn types.Otprn)
	GetOtprn(otprnHash common.Hash) *types.Otprn

	SaveLeague(otprnHash common.Hash, enode string)
	GetLeagueList(otprnHash common.Hash) []types.HeartBeat

	SaveVote(otprn common.Hash, blockNum *big.Int, vote *types.Voter)
	GetVoters(votekey common.Hash) []*types.Voter

	SaveFinalBlock(block *types.Block, byteBlock []byte) error
	GetBlock(blockHash common.Hash) *types.Block
	RemoveBlock(blockHash common.Hash)
	DeletedBlockChangeState(blockHash common.Hash)
}

type MemDatabase

type MemDatabase struct {
	CurBlock *types.Block
	CurOtprn *types.Otprn

	ConfigList map[common.Hash]types.ChainConfig

	NodeList   map[string]types.HeartBeat
	OtprnList  []types.Otprn
	LeagueList map[common.Hash]map[string]types.HeartBeat
	VoteList   map[common.Hash][]*types.Voter
	BlockChain []*types.Block
	// contains filtered or unexported fields
}

func NewMemDatabase

func NewMemDatabase() *MemDatabase

func (*MemDatabase) CurrentBlock

func (m *MemDatabase) CurrentBlock() *types.Block

func (*MemDatabase) CurrentInfo

func (m *MemDatabase) CurrentInfo() *types.CurrentInfo

func (*MemDatabase) CurrentOtprn

func (m *MemDatabase) CurrentOtprn() *types.Otprn

func (*MemDatabase) DeletedBlockChangeState added in v0.7.6

func (m *MemDatabase) DeletedBlockChangeState(blockHash common.Hash)

func (*MemDatabase) GetActiveNode

func (m *MemDatabase) GetActiveNode() []types.HeartBeat

func (*MemDatabase) GetBlock

func (m *MemDatabase) GetBlock(blockHash common.Hash) *types.Block

func (*MemDatabase) GetChainConfig

func (m *MemDatabase) GetChainConfig() *types.ChainConfig

func (*MemDatabase) GetLeagueList

func (m *MemDatabase) GetLeagueList(otprnHash common.Hash) []types.HeartBeat

func (*MemDatabase) GetOtprn

func (m *MemDatabase) GetOtprn(otprnHash common.Hash) *types.Otprn

func (*MemDatabase) GetVoters

func (m *MemDatabase) GetVoters(votekey common.Hash) []*types.Voter

func (*MemDatabase) InitActiveNode

func (m *MemDatabase) InitActiveNode()

func (*MemDatabase) RemoveActiveNode

func (m *MemDatabase) RemoveActiveNode(enode string)

func (*MemDatabase) RemoveBlock

func (m *MemDatabase) RemoveBlock(blockHash common.Hash)

func (*MemDatabase) SaveActiveNode

func (m *MemDatabase) SaveActiveNode(node types.HeartBeat)

func (*MemDatabase) SaveChainConfig

func (m *MemDatabase) SaveChainConfig(config *types.ChainConfig) error

func (*MemDatabase) SaveFinalBlock

func (m *MemDatabase) SaveFinalBlock(block *types.Block, byteBlock []byte) error

func (*MemDatabase) SaveLeague

func (m *MemDatabase) SaveLeague(otprnHash common.Hash, enode string)

func (*MemDatabase) SaveOtprn

func (m *MemDatabase) SaveOtprn(otprn types.Otprn)

func (*MemDatabase) SaveVote

func (m *MemDatabase) SaveVote(otprn common.Hash, blockNum *big.Int, vote *types.Voter)

func (*MemDatabase) Start

func (m *MemDatabase) Start() error

func (*MemDatabase) Stop

func (m *MemDatabase) Stop()

type MongoDatabase

type MongoDatabase struct {
	// contains filtered or unexported fields
}

func NewMongoDatabase

func NewMongoDatabase(conf config) (*MongoDatabase, error)

func (*MongoDatabase) CurrentBlock

func (m *MongoDatabase) CurrentBlock() *types.Block

func (*MongoDatabase) CurrentInfo

func (m *MongoDatabase) CurrentInfo() *types.CurrentInfo

func (*MongoDatabase) CurrentOtprn

func (m *MongoDatabase) CurrentOtprn() *types.Otprn

func (*MongoDatabase) DeletedBlockChangeState added in v0.7.6

func (m *MongoDatabase) DeletedBlockChangeState(blockHash common.Hash)

voter가 0일때 블록 번호를 -로 바꿔서 업데이트

func (*MongoDatabase) GetActiveFairnodes

func (m *MongoDatabase) GetActiveFairnodes() map[common.Hash]map[string]string

func (*MongoDatabase) GetActiveNode

func (m *MongoDatabase) GetActiveNode() []types.HeartBeat

func (*MongoDatabase) GetBlock

func (m *MongoDatabase) GetBlock(blockHash common.Hash) *types.Block

func (*MongoDatabase) GetChainConfig

func (m *MongoDatabase) GetChainConfig() *types.ChainConfig

func (*MongoDatabase) GetLeagueList

func (m *MongoDatabase) GetLeagueList(otprnHash common.Hash) []types.HeartBeat

func (*MongoDatabase) GetOtprn

func (m *MongoDatabase) GetOtprn(otprnHash common.Hash) *types.Otprn

func (*MongoDatabase) GetVoters

func (m *MongoDatabase) GetVoters(votekey common.Hash) []*types.Voter

func (*MongoDatabase) InitActiveNode

func (m *MongoDatabase) InitActiveNode()

Fairnode가 기동될 때, 기존 노드 정보를 지운다. (새로 갱신함)

func (*MongoDatabase) InsertActiveFairnode

func (m *MongoDatabase) InsertActiveFairnode(nodeKey common.Hash, address string)

func (*MongoDatabase) RemoveActiveFairnode

func (m *MongoDatabase) RemoveActiveFairnode(nodeKey common.Hash)

func (*MongoDatabase) RemoveActiveNode

func (m *MongoDatabase) RemoveActiveNode(enode string)

func (*MongoDatabase) RemoveBlock

func (m *MongoDatabase) RemoveBlock(blockHash common.Hash)

func (*MongoDatabase) SaveActiveNode

func (m *MongoDatabase) SaveActiveNode(node types.HeartBeat)

func (*MongoDatabase) SaveChainConfig

func (m *MongoDatabase) SaveChainConfig(config *types.ChainConfig) error

func (*MongoDatabase) SaveFinalBlock

func (m *MongoDatabase) SaveFinalBlock(block *types.Block, byteBlock []byte) error

func (*MongoDatabase) SaveLeague

func (m *MongoDatabase) SaveLeague(otprnHash common.Hash, enode string)

func (*MongoDatabase) SaveOtprn

func (m *MongoDatabase) SaveOtprn(otprn types.Otprn)

func (*MongoDatabase) SaveVote

func (m *MongoDatabase) SaveVote(otprn common.Hash, blockNum *big.Int, vote *types.Voter)

func (*MongoDatabase) Start

func (m *MongoDatabase) Start() error

func (*MongoDatabase) Stop

func (m *MongoDatabase) Stop()

func (*MongoDatabase) UpdateActiveFairnode

func (m *MongoDatabase) UpdateActiveFairnode(nodeKey common.Hash, status uint64)

Directories

Path Synopsis
this type for mongodb stored type
this type for mongodb stored type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL