Documentation ¶
Overview ¶
Package validator implements sealing and broadcasting blocks to the network.
The block sealing process is to go through all the transactions in the mempool and order them by nounce and later on construct an uncommitted balance which will be used to check if a transaction has enough balance and allowed to change the state of the blockchain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NetworkMessagePublisher ¶
type NetworkMessagePublisher interface {
PublishMessageToNetwork(ctx context.Context, topicName string, data []byte) error
}
NetworkMessagePublisher is a pub sub message broadcaster.
type UncommitedBalance ¶
type UncommitedBalance struct {
// contains filtered or unexported fields
}
UncommitedBalance represents an uncommitted balance of a user.
func NewUncommitedBalance ¶
func NewUncommitedBalance() UncommitedBalance
NewUncommitedBalance creates a new uncommitted balance.
func (*UncommitedBalance) InitializeBalanceAndNounceFor ¶
func (b *UncommitedBalance) InitializeBalanceAndNounceFor(address string, balance *big.Int, nounce uint64)
InitializeBalanceAndNounceFor sets the balance and nounce for an address.
func (*UncommitedBalance) IsInitialized ¶
func (b *UncommitedBalance) IsInitialized(address string) bool
IsInitialized checks if balance is initialized for an address.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator struct.
func New ¶
func New(node NetworkMessagePublisher, bchain blockchain.Interface, privateKeys []crypto.PrivKey) (*Validator, error)
New constructs a new validator.
func (*Validator) BroadcastBlock ¶
BroadcastBlock broadcasts a block to the network.