Documentation ¶
Index ¶
- Variables
- func Check(i *Item) error
- func CheckIncoming(stored, incoming *Item) error
- func Sign(k ed25519.PrivateKey, salt []byte, seq int64, bv []byte) []byte
- func Verify(k ed25519.PublicKey, salt []byte, seq int64, bv []byte, sig []byte) bool
- type Item
- type Memory
- type Put
- type Store
- type Target
- type Wrapper
Constants ¶
This section is empty.
Variables ¶
var ( ErrValueFieldTooBig = krpc.Error{ Code: krpc.ErrorCodeMessageValueFieldTooBig, Msg: "message (v field) too big", } ErrInvalidSignature = krpc.Error{ Code: krpc.ErrorCodeInvalidSignature, Msg: "invalid signature", } ErrSaltFieldTooBig = krpc.Error{ Code: krpc.ErrorCodeSaltFieldTooBig, Msg: "salt (salt field) too big", } ErrCasHashMismatched = krpc.Error{ Code: krpc.ErrorCodeCasHashMismatched, Msg: "the CAS hash mismatched, re-read value and try again", } ErrSequenceNumberLessThanCurrent = krpc.Error{ Code: krpc.ErrorCodeSequenceNumberLessThanCurrent, Msg: "sequence number less than current", } )
var Empty32ByteArray [32]byte
var ErrItemNotFound = errors.New("item not found")
Functions ¶
func CheckIncoming ¶
Types ¶
type Item ¶
type Item struct { // Value to be stored V interface{} // 32 byte ed25519 public key K [32]byte Salt []byte Sig [64]byte Cas int64 Seq int64 // contains filtered or unexported fields }
func NewItem ¶
NewItem creates a new arbitrary DHT element. The distinction between storing mutable and immutable items is the inclusion of a public key, a sequence number, signature and an optional salt.
cas parameter is short for compare and swap, it has similar semantics as CAS CPU instructions. It is used to avoid race conditions when multiple nodes are writing to the same slot in the DHT. It is optional. If present it specifies the sequence number of the data blob being overwritten by the put.
salt parameter is used to make possible several targets using the same private key.
The optional seq field specifies that an item's value should only be sent if its sequence number is greater than the given value.