parser

package
v0.0.0-...-42a6357 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompactSize

func CompactSize(n uint64) []byte

CompactSize convert an int to a series of 1 to 8 bytes Used for scriptLength, NVin, NVout, witnessCount

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer allows to use the Reader interface when storing data in memory

func (*Buffer) Close

func (buf *Buffer) Close()

Close buffer TODO: Is it relevant for Buffer?

func (*Buffer) Peek

func (buf *Buffer) Peek(length int) ([]byte, error)

Peek up to length without moving cursor

func (*Buffer) ReadByte

func (buf *Buffer) ReadByte() (byte, error)

ReadByte reads next one byte of data

func (*Buffer) ReadBytes

func (buf *Buffer) ReadBytes(length uint64) []byte

ReadBytes reads next length bytes of data

func (*Buffer) ReadCompactSize

func (buf *Buffer) ReadCompactSize() uint64

ReadCompactSize reads N byte of data as uint64, LE. N depends on the first byte

func (*Buffer) ReadInt32

func (buf *Buffer) ReadInt32() int32

ReadInt32 reads next 8 bytes of data as int32, LE

func (*Buffer) ReadInt64

func (buf *Buffer) ReadInt64() int64

ReadInt64 reads next 16 bytes of data as int64, LE

func (*Buffer) ReadUint16

func (buf *Buffer) ReadUint16() uint16

ReadUint16 reads next 4 bytes of data as uint16, LE

func (*Buffer) ReadUint32

func (buf *Buffer) ReadUint32() uint32

ReadUint32 reads next 8 bytes of data as uint32, LE

func (*Buffer) ReadUint64

func (buf *Buffer) ReadUint64() uint64

ReadUint64 reads next 16 bytes of data as uint64, LE

func (*Buffer) ReadVarint

func (buf *Buffer) ReadVarint() uint64

ReadVarint reads N byte of data as uint64, LE. N depends on the first byte

func (*Buffer) Reset

func (buf *Buffer) Reset()

Reset cursor to position 0

func (*Buffer) Seek

func (buf *Buffer) Seek(pos int64, whence int) (int64, error)

Seek moves cursor tu position pos

func (*Buffer) Type

func (buf *Buffer) Type() string

Type returns type of reader

type File

type File struct {
	NFile uint32 // file number
	// contains filtered or unexported fields
}

File allows to use the Reader interface when reading a file

func (*File) Close

func (file *File) Close()

Close file

func (*File) Peek

func (file *File) Peek(length int) ([]byte, error)

Peek read length bytes without moving cursor

func (*File) ReadByte

func (file *File) ReadByte() (byte, error)

ReadByte reads next one byte of data

func (*File) ReadBytes

func (file *File) ReadBytes(length uint64) []byte

ReadBytes reads next length bytes of data

func (*File) ReadCompactSize

func (file *File) ReadCompactSize() uint64

ReadCompactSize reads N byte of data as uint64, LE. N depends on the first byte

func (*File) ReadInt32

func (file *File) ReadInt32() int32

ReadInt32 reads next 8 bytes of data as int32, LE

func (*File) ReadInt64

func (file *File) ReadInt64() int64

ReadInt64 reads next 16 bytes of data as int64, LE

func (*File) ReadUint16

func (file *File) ReadUint16() uint16

ReadUint16 reads next 4 bytes of data as uint16, LE

func (*File) ReadUint32

func (file *File) ReadUint32() uint32

ReadUint32 reads next 8 bytes of data as uint32, LE

func (*File) ReadUint64

func (file *File) ReadUint64() uint64

ReadUint64 reads next 16 bytes of data as uint64, LE

func (*File) ReadVarint

func (file *File) ReadVarint() uint64

ReadVarint does not work for file TODO: Implement it

func (*File) Reset

func (file *File) Reset()

Reset sets cursor's position to 0

func (*File) Seek

func (file *File) Seek(offset int64, whence int) (int64, error)

Seek moves cursor's position to offset

func (*File) Size

func (file *File) Size() (int64, error)

Size returns the size of a file

func (*File) Type

func (file *File) Type() string

Type returns "file"

type Reader

type Reader interface {
	Type() string
	Peek(int) ([]byte, error)
	Seek(int64, int) (int64, error)
	Reset()
	ReadByte() (byte, error)
	ReadBytes(uint64) []byte
	ReadUint32() uint32
	ReadUint64() uint64
	ReadInt32() int32
	ReadVarint() uint64
	ReadCompactSize() uint64

	ReadUint16() uint16
	Close()
}

Reader is an interface used to decode blocks and transactions it allows to apply the same functions to files and buffers

func New

func New(x interface{}) (Reader, error)

New allows to declare a new Reader interface from a file or from raw data

Jump to

Keyboard shortcuts

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