node

package
v0.0.0-...-ecaa456 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_REQ_TIME = 20 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID []byte
var (
	MAX_ID  ID = []byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
	ZERO_ID ID = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
)

Fixed Identifer space of 160 bits * [Note] this works for hex base ids the identifier is a []byte each entry contains 2 digits TODO make it works for generic id radixes

func (ID) AddOne

func (id ID) AddOne(from int) ID

AddOne adds one starting from a specific digit and carrys up

func (ID) Equal

func (id ID) Equal(a ID) bool

func (ID) InLRXRange

func (id ID) InLRXRange(a, b ID) bool

func (ID) InLXRange

func (id ID) InLXRange(a, b ID) bool

function checks if the id is in left execlusive range id is in the range (a, b]

func (ID) LeftShift

func (id ID) LeftShift() (ID, byte)

func (ID) Less

func (id ID) Less(a ID) bool

checks that id is befor a in the ring

func (ID) MaskLowerWith

func (id ID) MaskLowerWith(x ID, i int) ID

changes the lower i bits of id with the heighest i bits of x

func (ID) String

func (id ID) String() string

func (ID) TopShift

func (id ID) TopShift(a ID) ID

type Localnode

type Localnode struct {
	pd.UnimplementedKoordeServer
	Peer
	D            *Peer
	DParents     []*Peer
	Successor    *Peer
	Predecessor  *Peer
	NodeShutdown chan bool

	// mock consensus
	ConsensusAPI *mock.Consensus
	// dsever
	DClient client.Client
	// contains filtered or unexported fields
}

func (*Localnode) AddDParentRPC

func (ln *Localnode) AddDParentRPC(bctx context.Context, p *pd.PeerPacket) (*pd.Empty, error)

func (*Localnode) BootStarpRPC

func (ln *Localnode) BootStarpRPC(bctx context.Context, bootstrapPacket *pd.BootStrapPacket) (*pd.BootStrapReply, error)

func (*Localnode) BroadCast

func (ln *Localnode) BroadCast(info string) error

func (*Localnode) BroadCastRPC

func (ln *Localnode) BroadCastRPC(ctx context.Context, b *pd.BlockPacket) (*pd.Empty, error)

func (*Localnode) DGetBlocks

func (n *Localnode) DGetBlocks(ctx context.Context, e *pd.Empty) (*pd.BlocksPacket, error)

func (*Localnode) DGetID

func (n *Localnode) DGetID(ctx context.Context, e *pd.Empty) (*pd.PeerPacket, error)

func (*Localnode) DGetPointers

func (n *Localnode) DGetPointers(ctx context.Context, e *pd.Empty) (*pd.Pointers, error)

func (*Localnode) DJoin

func (n *Localnode) DJoin(ctx context.Context, p *pd.PeerPacket) (*pd.Empty, error)

func (*Localnode) DLKup

func (n *Localnode) DLKup(ctx context.Context, p *pd.PeerPacket) (*pd.PeerPacket, error)

func (*Localnode) DSetD

func (n *Localnode) DSetD(ctx context.Context, p *pd.PeerPacket) (*pd.Empty, error)

func (*Localnode) DSetSuccessor

func (n *Localnode) DSetSuccessor(ctx context.Context, p *pd.PeerPacket) (*pd.Empty, error)

func (*Localnode) GetID

func (ln *Localnode) GetID() string

func (*Localnode) GetLocalBlocks

func (ln *Localnode) GetLocalBlocks() []mock.Block

func (*Localnode) GetPredecessorRPC

func (ln *Localnode) GetPredecessorRPC(ctx context.Context, e *pd.Empty) (*pd.PeerPacket, error)

func (*Localnode) GetSuccessorRPC

func (ln *Localnode) GetSuccessorRPC(ctx context.Context, e *pd.Empty) (*pd.PeerPacket, error)

func (*Localnode) Init

func (ln *Localnode) Init(cxt context.Context) error

Init initializes the first node in the network It inits the Successor, D pointers with default values (node itslef)

func (*Localnode) InitBroadCastRPC

func (n *Localnode) InitBroadCastRPC(ctx context.Context, b *pd.BlockPacket) (*pd.Empty, error)

func (*Localnode) Join

func (ln *Localnode) Join(nodeAddr *net.TCPAddr, port int) error

Join initializes the node by executing Chord Join Algorithm It inits the Successor, D pointers

func (*Localnode) Lookup

func (ln *Localnode) Lookup(k ID) (*Peer, int32, error)

func (*Localnode) LookupRPC

func (ln *Localnode) LookupRPC(bctx context.Context, lookupPacket *pd.LookupPacket) (*pd.PeerPacket, error)

func (*Localnode) NotifyRPC

func (ln *Localnode) NotifyRPC(ctx context.Context, p *pd.PeerPacket) (*pd.Empty, error)

func (*Localnode) RemoveDParentRPC

func (ln *Localnode) RemoveDParentRPC(btcx context.Context, p *pd.PeerPacket) (*pd.Empty, error)

func (*Localnode) UpdateDPointerRPC

func (ln *Localnode) UpdateDPointerRPC(bctx context.Context, p *pd.PeerPacket) (*pd.Empty, error)

func (*Localnode) UpdatePredecessorRPC

func (ln *Localnode) UpdatePredecessorRPC(bctx context.Context, p *pd.PeerPacket) (*pd.PeerPacket, error)

func (*Localnode) UpdateSuccessorRPC

func (ln *Localnode) UpdateSuccessorRPC(bctx context.Context, p *pd.PeerListPacket) (*pd.PeerListPacket, error)

type Peer

type Peer struct {
	NetAddr  *net.TCPAddr
	NodeAddr ID
	Start    ID
	Interval []ID
	// contains filtered or unexported fields
}

func (*Peer) CloseConnection

func (p *Peer) CloseConnection()

func (*Peer) InitConnection

func (p *Peer) InitConnection() error

Jump to

Keyboard shortcuts

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