Documentation ¶
Index ¶
- Constants
- Variables
- func Fatalf(format string, args ...interface{})
- func GenUpdateRaftConfigJson(enode []byte, path string) (uint16, error)
- func GetRaftConfigJson(path string) (uint16, error)
- func GetRaftIdFromEnodeId(enode []byte) uint16
- func GetRandomRaftIdFromEnodeId(enode []byte) (uint16, error)
- func NewStoppableListener(addr string, stopc <-chan struct{}) (*stoppableListener, error)
- func ReadGenRaftConfigJson(enode []byte, path string) (uint16, error)
- type Address
- type AddressTxes
- type ExtraSeal
- type InvalidRaftOrdering
- type Peer
- type Raft
- type SealContext
- type SpeculativeChain
- func (chain *SpeculativeChain) Accept(acceptedBlock *types.Block)
- func (chain *SpeculativeChain) Clear(block *types.Block)
- func (chain *SpeculativeChain) Extend(block *types.Block)
- func (chain *SpeculativeChain) Head() *types.Block
- func (chain *SpeculativeChain) SetHead(block *types.Block)
- func (chain *SpeculativeChain) UnwindFrom(invalidHash common.Hash, headBlock *types.Block)
- func (chain *SpeculativeChain) WithoutProposedTxes(txes types.Transactions) types.Transactions
- func (chain *SpeculativeChain) WithoutProposedTxes2(addrTxes AddressTxes) AddressTxes
Constants ¶
const ( MinterRole = etcdRaft.LEADER TickerMS = 100 // Raft's ticker interval SnapshotPeriod = 250 // Snapshot after this many raft messages )
Variables ¶
var ( BlockReward *big.Int = new(big.Int).Mul(big.NewInt(1e+18), big.NewInt(20)) BlockAttenuation *big.Int = big.NewInt(2500000) )
var (
AppliedDbKey = []byte("applied")
)
var ExtraVanity = 32 // Fixed number of extra-data prefix bytes reserved for arbitrary signer vanity
Functions ¶
func Fatalf ¶
func Fatalf(format string, args ...interface{})
TODO: this is just copied over from cmd/utils/cmd.go. dedupe Fatalf formats a message to standard error and exits the program. The message is also printed to standard output if standard error is redirected to a different file.
func GenUpdateRaftConfigJson ¶
func GetRaftConfigJson ¶
func GetRaftIdFromEnodeId ¶
func NewStoppableListener ¶
Types ¶
type Address ¶
type Address struct { RaftId uint16 `json:"raftId"` NodeId enode.EnodeID `json:"nodeId"` Ip net.IP `json:"ip"` P2pPort enr.TCP `json:"p2pPort"` RaftPort enr.RaftPort `json:"raftPort"` }
Serializable information about a Peer. Sufficient to build `etcdRaft.Peer` or `enode.Node`. As NodeId is mainly used to derive the `ecdsa.pubkey` to build `enode.Node` it is kept as [64]byte instead of ID [32]byte used by `enode.Node`.
func BytesToAddress ¶
type AddressTxes ¶
type AddressTxes map[common.Address]types.Transactions
type InvalidRaftOrdering ¶
type Peer ¶
type Peer struct { Address *Address // For raft transport P2pNode *enode.Node // For ethereum transport }
A peer that we're connected to via both raft's http transport, and ethereum p2p
type Raft ¶
func New ¶
func New(nodeKey *ecdsa.PrivateKey) *Raft
func (*Raft) FinalizeAndAssemble ¶
type SealContext ¶
type SealContext struct { InvalidRaftOrderingChan chan InvalidRaftOrdering SpeculativeChain *SpeculativeChain ShouldMine *channels.RingChannel }
type SpeculativeChain ¶
type SpeculativeChain struct {
// contains filtered or unexported fields
}
The speculative chain represents blocks that we have minted which haven't been accepted into the chain yet, building on each other in a chain. It has three basic operations: * add new block to end * accept / remove oldest block * unwind / remove invalid blocks to the end
Additionally: * clear state when we stop minting * set the parent when we're not minting (so it's always current)
func NewSpeculativeChain ¶
func NewSpeculativeChain() *SpeculativeChain
func (*SpeculativeChain) Accept ¶
func (chain *SpeculativeChain) Accept(acceptedBlock *types.Block)
Accept this block, removing it from the speculative chain
func (*SpeculativeChain) Clear ¶
func (chain *SpeculativeChain) Clear(block *types.Block)
func (*SpeculativeChain) Extend ¶
func (chain *SpeculativeChain) Extend(block *types.Block)
Append a new speculative block
func (*SpeculativeChain) Head ¶
func (chain *SpeculativeChain) Head() *types.Block
func (*SpeculativeChain) SetHead ¶
func (chain *SpeculativeChain) SetHead(block *types.Block)
Set the parent of the speculative chain
Note: This is only called when not minter
func (*SpeculativeChain) UnwindFrom ¶
func (chain *SpeculativeChain) UnwindFrom(invalidHash common.Hash, headBlock *types.Block)
Remove all blocks in the chain from the specified one until the end
func (*SpeculativeChain) WithoutProposedTxes ¶
func (chain *SpeculativeChain) WithoutProposedTxes(txes types.Transactions) types.Transactions
func (*SpeculativeChain) WithoutProposedTxes2 ¶
func (chain *SpeculativeChain) WithoutProposedTxes2(addrTxes AddressTxes) AddressTxes