chord

package
v0.0.0-...-19cc977 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	M      = 160
	SucLen = 20

	MaintainInterval = second / 4
)

Variables

This section is empty.

Functions

func Dial

func Dial(ip string) *rpc.Client

func GetLocalAddress

func GetLocalAddress() string

func Ping

func Ping(addr string) bool

Types

type IP

type IP struct {
	Addr string
	Id   big.Int
}

type KVMap

type KVMap struct {
	Map  map[string]string
	Lock sync.Mutex
}

type KVPair

type KVPair struct {
	Key, Value string
}

type Node

type Node struct {
	Self   IP
	Finger [M]IP
	Pre    IP
	Suc    [SucLen]IP

	Data    KVMap
	DataPre KVMap
	Lock    sync.Mutex

	On     bool
	Joined bool
	Server *rpc.Server
	Listen net.Listener
	// contains filtered or unexported fields
}

func (*Node) CheckPre

func (n *Node) CheckPre() error

func (*Node) ClosestPrecedingNode

func (n *Node) ClosestPrecedingNode(id *big.Int) IP

func (*Node) Create

func (n *Node) Create() error

func (*Node) Delete

func (n *Node) Delete(key string) bool

func (*Node) DeleteDataPre

func (n *Node) DeleteDataPre(key string, _ *bool) error

func (*Node) DeleteInside

func (n *Node) DeleteInside(key string, _ *bool) error

func (*Node) ExtractData

func (n *Node) ExtractData(id *big.Int, ret *map[string]string) error

func (*Node) FindSuc

func (n *Node) FindSuc(id *big.Int, ret *IP) error

func (*Node) FixSuc

func (n *Node) FixSuc() error

func (*Node) Get

func (n *Node) Get(key string) (bool, string)

func (*Node) GetData

func (n *Node) GetData(_ *int, ret *map[string]string) error

func (*Node) GetInside

func (n *Node) GetInside(key string, val *string) error

func (*Node) GetPre

func (n *Node) GetPre(_ *int, ret *IP) error

func (*Node) Id

func (n *Node) Id(_ *int, ret *big.Int) error

func (*Node) ImportData

func (n *Node) ImportData(dat map[string]string, _ *bool) error

func (*Node) Init

func (n *Node) Init(port string)

func (*Node) Join

func (n *Node) Join(ip string) error

func (*Node) Maintain

func (n *Node) Maintain()

func (*Node) MaintainSuc

func (n *Node) MaintainSuc() error

func (*Node) MergeDataPre

func (n *Node) MergeDataPre()

func (*Node) Notify

func (n *Node) Notify(pre *IP, suc *bool) error

func (*Node) Put

func (n *Node) Put(key, val string) error

func (*Node) PutDataPre

func (n *Node) PutDataPre(kv KVPair, _ *bool) error

func (*Node) PutInside

func (n *Node) PutInside(kv KVPair, _ *bool) error

func (*Node) Quit

func (n *Node) Quit() error

func (*Node) Run

func (n *Node) Run()

func (*Node) SetDataPre

func (n *Node) SetDataPre(dat map[string]string, _ *bool) error

func (*Node) SetSuc

func (n *Node) SetSuc(suc *[SucLen - 1]IP, _ *bool) error

func (*Node) Stablize

func (n *Node) Stablize() error

func (*Node) Stop

func (n *Node) Stop()

func (*Node) UpdatePre

func (n *Node) UpdatePre(ip *IP, _ *bool) error

func (*Node) UpdateSuc

func (n *Node) UpdateSuc(suc *IP, _ *bool) error

Jump to

Keyboard shortcuts

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