INNER CODE UNIT · Go

NewBatch

lightningnetwork/lightning-onion · batch.go:41

func NewBatch(id []byte) *Batch {
	return &Batch{
		ID:          id,
		ReplaySet:   NewReplaySet(),
		entries:     make(map[uint16]batchEntry),
		replayCache: make(map[HashPrefix]struct{}),
	}
}

// Put inserts a hash-prefix/CLTV pair into the current batch. This method only
// returns an error in the event that the batch was already committed to disk.
// Decisions regarding whether or not a particular sequence number is a replay
// is ultimately reported via the batch's ReplaySet after committing to disk.
func (b *Batch) Put(seqNum uint16, hashPrefix *HashPrefix, cltv uint32) error {
	// Abort if this batch was already written to disk.
	if b.IsCommitted {
		return ErrAlreadyCommitted
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…