pubkeymanager

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MockPubkey = "ddpub1addwnpepqt8tnluxnk3y5quyq952klgqnlmz2vmaynm40fp592s0um7ucvjh5lc2l2z"
)

Functions

This section is empty.

Types

type MockPoolAddressValidator

type MockPoolAddressValidator struct{}

func NewMockPoolAddressValidator

func NewMockPoolAddressValidator() *MockPoolAddressValidator

func (*MockPoolAddressValidator) AddNodePubKey

func (mpa *MockPoolAddressValidator) AddNodePubKey(pk common.PubKey)

func (*MockPoolAddressValidator) AddPubKey

func (mpa *MockPoolAddressValidator) AddPubKey(pk common.PubKey, _ bool)

func (*MockPoolAddressValidator) GetContract

func (mpa *MockPoolAddressValidator) GetContract(chain common.Chain, pk common.PubKey) common.Address

func (*MockPoolAddressValidator) GetContracts

func (mpa *MockPoolAddressValidator) GetContracts(chain common.Chain) []common.Address

func (*MockPoolAddressValidator) GetNodePubKey

func (mpa *MockPoolAddressValidator) GetNodePubKey() common.PubKey

func (*MockPoolAddressValidator) GetPubKeys

func (mpa *MockPoolAddressValidator) GetPubKeys() common.PubKeys

func (*MockPoolAddressValidator) GetSignPubKeys

func (mpa *MockPoolAddressValidator) GetSignPubKeys() common.PubKeys

func (*MockPoolAddressValidator) HasPubKey

func (mpa *MockPoolAddressValidator) HasPubKey(pk common.PubKey) bool

func (*MockPoolAddressValidator) IsValidPoolAddress

func (mpa *MockPoolAddressValidator) IsValidPoolAddress(addr string, chain common.Chain) (bool, common.ChainPoolInfo)

func (*MockPoolAddressValidator) RegisterCallback

func (mpa *MockPoolAddressValidator) RegisterCallback(callback OnNewPubKey)

func (*MockPoolAddressValidator) RemovePubKey

func (mpa *MockPoolAddressValidator) RemovePubKey(pk common.PubKey)

func (*MockPoolAddressValidator) Start

func (mpa *MockPoolAddressValidator) Start() error

func (*MockPoolAddressValidator) Stop

func (mpa *MockPoolAddressValidator) Stop() error

type OnNewPubKey

type OnNewPubKey func(pk common.PubKey) error

OnNewPubKey is a function that used as a callback , if somehow we need to do additional process when a new pubkey get added

type PubKeyManager

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

PubKeyManager manager an always up to date pubkeys , which implement PubKeyValidator interface

func NewPubKeyManager

func NewPubKeyManager(bridge digitalclient.DigitaldollarBridge, m *metrics.Metrics) (*PubKeyManager, error)

NewPubKeyManager create a new instance of PubKeyManager

func (*PubKeyManager) AddNodePubKey

func (pkm *PubKeyManager) AddNodePubKey(pk common.PubKey)

AddNodePubKey add the given public key as a node public key to internal storage

func (*PubKeyManager) AddPubKey

func (pkm *PubKeyManager) AddPubKey(pk common.PubKey, signer bool)

AddPubKey add the given public key to internal storage

func (*PubKeyManager) GetContract

func (pkm *PubKeyManager) GetContract(chain common.Chain, pubKey common.PubKey) common.Address

GetContract return the contract address that match the given chain and pubkey

func (*PubKeyManager) GetContracts

func (pkm *PubKeyManager) GetContracts(chain common.Chain) []common.Address

GetContracts return all the contracts for the requested chain

func (*PubKeyManager) GetNodePubKey

func (pkm *PubKeyManager) GetNodePubKey() common.PubKey

GetNodePubKey get node account pub key

func (*PubKeyManager) GetPubKeys

func (pkm *PubKeyManager) GetPubKeys() common.PubKeys

GetPubKeys return all the public keys managed by this PubKeyManager

func (*PubKeyManager) GetSignPubKeys

func (pkm *PubKeyManager) GetSignPubKeys() common.PubKeys

GetSignPubKeys get all the public keys that local node is a signer

func (*PubKeyManager) HasPubKey

func (pkm *PubKeyManager) HasPubKey(pk common.PubKey) bool

HasPubKey return true if the given public key exist

func (*PubKeyManager) IsValidPoolAddress

func (pkm *PubKeyManager) IsValidPoolAddress(addr string, chain common.Chain) (bool, common.ChainPoolInfo)

IsValidPoolAddress check whether the given address is a pool addr

func (*PubKeyManager) RegisterCallback

func (pkm *PubKeyManager) RegisterCallback(callback OnNewPubKey)

RegisterCallback register a call back that will be fired when a new key get added into the local memory storage

func (*PubKeyManager) RemovePubKey

func (pkm *PubKeyManager) RemovePubKey(pk common.PubKey)

RemovePubKey remove the given public key from internal storage

func (*PubKeyManager) Start

func (pkm *PubKeyManager) Start() error

Start to poll pubkeys from digitaldollar

func (*PubKeyManager) Stop

func (pkm *PubKeyManager) Stop() error

Stop pubkey manager

type PubKeyValidator

type PubKeyValidator interface {
	IsValidPoolAddress(addr string, chain common.Chain) (bool, common.ChainPoolInfo)
	HasPubKey(pk common.PubKey) bool
	AddPubKey(pk common.PubKey, _ bool)
	AddNodePubKey(pk common.PubKey)
	RemovePubKey(pk common.PubKey)
	GetSignPubKeys() common.PubKeys
	GetNodePubKey() common.PubKey
	GetPubKeys() common.PubKeys
	RegisterCallback(callback OnNewPubKey)
	GetContracts(chain common.Chain) []common.Address
	GetContract(chain common.Chain, pk common.PubKey) common.Address
}

PubKeyValidator define the method that can be used to interact with public keys

Jump to

Keyboard shortcuts

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