func (s *State) PutCommit(hash interfaces.IHash, msg interfaces.IMsg) { cs := s.Commits[hash.Fixed()] if cs == nil { cs = make([]interfaces.IMsg, 0) } s.Commits[hash.Fixed()] = append(cs, msg) }
// Returns the oldest, not processed, Commit received func (s *State) NextCommit(hash interfaces.IHash) interfaces.IMsg { cs := s.Commits[hash.Fixed()] if cs == nil { return nil } if len(cs) == 0 { delete(s.Commits, hash.Fixed()) return nil } r := cs[0] copy(cs[:], cs[1:]) cs[len(cs)-1] = nil s.Commits[hash.Fixed()] = cs[:len(cs)-1] return r }
// Checks if the timestamp is valid. If the timestamp is too old or // too far into the future, then we don't consider it valid. Or if we // have seen this hash before, then it is not valid. To that end, // this code remembers hashes tested in the past, and rejects the // second submission of the same hash. func (r *Replay) IsTSValid(mask int, hash interfaces.IHash, timestamp interfaces.Timestamp) bool { return r.IsTSValid_(mask, hash.Fixed(), timestamp, primitives.NewTimestampNow()) }
func (p *ProcessList) AddNewEntry(key interfaces.IHash, value interfaces.IEntry) { p.NewEntriesMutex.Lock() defer p.NewEntriesMutex.Unlock() p.NewEntries[key.Fixed()] = value }
func (p *ProcessList) DeleteNewEntry(key interfaces.IHash) { p.NewEntriesMutex.Lock() defer p.NewEntriesMutex.Unlock() delete(p.NewEntries, key.Fixed()) }
func (p *ProcessList) DeleteEBlocks(key interfaces.IHash) { p.neweblockslock.Lock() defer p.neweblockslock.Unlock() delete(p.NewEBlocks, key.Fixed()) }
func (p *ProcessList) GetNewEBlocks(key interfaces.IHash) interfaces.IEntryBlock { p.neweblockslock.Lock() defer p.neweblockslock.Unlock() return p.NewEBlocks[key.Fixed()] }
func (p *ProcessList) AddNewEBlocks(key interfaces.IHash, value interfaces.IEntryBlock) { p.neweblockslock.Lock() defer p.neweblockslock.Unlock() p.NewEBlocks[key.Fixed()] = value }
func (p *ProcessList) GetOldMsgs(key interfaces.IHash) interfaces.IMsg { p.oldmsgslock.Lock() defer p.oldmsgslock.Unlock() return p.OldMsgs[key.Fixed()] }
func (p *ProcessList) DeleteOldMsgs(key interfaces.IHash) { p.oldmsgslock.Lock() defer p.oldmsgslock.Unlock() delete(p.OldMsgs, key.Fixed()) }