Show / Hide Table of Contents

Class MessageCache

Cache object that stores recently seen Messages.

Inheritance
Object
MessageCache
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Net.Consensus
Assembly: Libplanet.Net.dll
Syntax
public class MessageCache

Constructors

| Improve this Doc View Source

MessageCache(Int32, Int32)

Create a message cache instance that stores recently seen Messages for gossip.

Declaration
public MessageCache(int len, int gossip)
Parameters
Type Name Description
Int32 len

Size of the cache history window.

Int32 gossip

Maximum number of windows to be selected for gossip.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown when len is less than or equal to 0, or gossip is less than or equal to 0 or greater than len.

Methods

| Improve this Doc View Source

Get(MessageId)

Gets copied value of the message with id if it exists in the message cache.

Declaration
[Pure]
public MessageContent Get(MessageId id)
Parameters
Type Name Description
MessageId id

A MessageId of the Message to get.

Returns
Type Description
MessageContent

A message with id id.

Exceptions
Type Condition
KeyNotFoundException

Thrown when a Message of id id does not exist in the message cache.

| Improve this Doc View Source

GetGossipIds()

Selects at maximum gossip messages used for gossiping.

Declaration
[Pure]
public MessageId[] GetGossipIds()
Returns
Type Description
MessageId[]

A list of message ids to gossip.

| Improve this Doc View Source

Put(MessageContent)

Puts the message into message cache.

Declaration
public void Put(MessageContent message)
Parameters
Type Name Description
MessageContent message

A Message to cache.

Exceptions
Type Condition
ArgumentException

Thrown when a Message with the same id already exists.

| Improve this Doc View Source

Shift()

Shifts the current window and discard messages older than the history length of the cache.

Declaration
public void Shift()
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium