MCPcopy Create free account
hub / github.com/chain/txvm / AddTx

Method AddTx

protocol/builder.go:78–99  ·  view source on GitHub ↗
(tx *bc.CommitmentsTx)

Source from the content-addressed store, hash-verified

76)
77
78func (bb *BlockBuilder) AddTx(tx *bc.CommitmentsTx) error {
79 if len(bb.txs) >= bb.MaxBlockTxs {
80 return ErrBlockFull
81 }
82 err := bb.checkTransactionTime(tx.Tx, bb.timestampMS)
83 if err != nil {
84 return err
85 }
86 runlimit, ok := checked.AddInt64(bb.runlimit, tx.Tx.Runlimit)
87 if !ok {
88 return ErrBlockRunlimit
89 }
90 err = bb.snapshot.ApplyTx(tx)
91 if err != nil {
92 return err
93 }
94
95 bb.runlimit = runlimit
96 bb.txs = append(bb.txs, tx)
97
98 return nil
99}
100
101func (bb *BlockBuilder) Build() (*bc.UnsignedBlock, *state.Snapshot, error) {
102 prev := bb.snapshot.Header

Callers 2

buildFunction · 0.95
GenerateBlockMethod · 0.80

Calls 3

checkTransactionTimeMethod · 0.95
AddInt64Function · 0.92
ApplyTxMethod · 0.80

Tested by

no test coverage detected